From 6945d3a6da2e62e9a209be9eb4c01e890f87b492 Mon Sep 17 00:00:00 2001 From: gavinking Date: Sun, 27 Sep 2015 13:37:45 +0200 Subject: [PATCH] basic support for "package." qualified constructors --- Ceylon.g | 12 +++++++++++- Ceylon.nodes | 2 ++ .../typechecker/analyzer/DeclarationVisitor.java | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Ceylon.g b/Ceylon.g index 9441fb437..d13365933 100644 --- a/Ceylon.g +++ b/Ceylon.g @@ -356,6 +356,11 @@ typeNameDeclaration returns [Identifier identifier] enumeratedObject returns [Enumerated declaration] : NEW { $declaration = new Enumerated($NEW); } + ( + PACKAGE + { $declaration.setPromoted(true); } + MEMBER_OP + )? ( memberNameDeclaration { $declaration.setIdentifier($memberNameDeclaration.identifier); } @@ -881,6 +886,11 @@ classDeclaration returns [AnyClass declaration] constructor returns [Constructor declaration] : NEW { $declaration = new Constructor($NEW); } + ( + PACKAGE + { $declaration.setPromoted(true); } + MEMBER_OP + )? ( memberNameDeclaration { $declaration.setIdentifier($memberNameDeclaration.identifier); } @@ -1485,7 +1495,7 @@ declaration returns [Declaration declaration] { $declaration=$inferredAttributeDeclaration.declaration; } | typedMethodOrAttributeDeclaration { $declaration=$typedMethodOrAttributeDeclaration.declaration; } - | (NEW (LIDENTIFIER|UIDENTIFIER)? LPAREN) => + | (NEW (PACKAGE MEMBER_OP)? (LIDENTIFIER|UIDENTIFIER)? LPAREN) => constructor { $declaration=$constructor.declaration; } | enumeratedObject diff --git a/Ceylon.nodes b/Ceylon.nodes index ade86ae93..1a69656f3 100644 --- a/Ceylon.nodes +++ b/Ceylon.nodes @@ -143,6 +143,7 @@ ^(ENUMERATED:DECLARATION DELEGATED_CONSTRUCTOR? BLOCK + boolean promoted; Value declarationModel; Constructor enumerated;) @@ -151,6 +152,7 @@ PARAMETER_LIST? DELEGATED_CONSTRUCTOR? BLOCK + boolean promoted; Function declarationModel; Constructor constructor;) diff --git a/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java b/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java index 521aee13e..1744f2e76 100644 --- a/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java +++ b/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java @@ -861,6 +861,9 @@ public void visit(Tree.Constructor that) { Scope o = enterScope(c); super.visit(that); exitScope(o); + if (that.getPromoted()) { + f.setContainer(pkg); + } f.setImplemented(that.getBlock() != null); if (that.getParameterList()==null) { that.addError("missing parameter list in constructor declaration: '" + @@ -943,6 +946,9 @@ else if (scope.getContainer() instanceof Interface) { Scope o = enterScope(e); super.visit(that); exitScope(o); + if (that.getPromoted()) { + v.setContainer(pkg); + } v.setImplemented(that.getBlock() != null); }