Skip to content

Commit

Permalink
basic support for "package." qualified constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Sep 27, 2015
1 parent 39ae693 commit 6945d3a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Ceylon.g
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -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); }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Ceylon.nodes
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
^(ENUMERATED:DECLARATION
DELEGATED_CONSTRUCTOR?
BLOCK
boolean promoted;
Value declarationModel;
Constructor enumerated;)

Expand All @@ -151,6 +152,7 @@
PARAMETER_LIST?
DELEGATED_CONSTRUCTOR?
BLOCK
boolean promoted;
Function declarationModel;
Constructor constructor;)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '" +
Expand Down Expand Up @@ -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);
}

Expand Down

1 comment on commit 6945d3a

@gavinking
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For #1428, naturally.

Please sign in to comment.