Skip to content

Commit

Permalink
functions with dynamically typed params #600
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Feb 13, 2013
1 parent ec0c077 commit 5d49391
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Ceylon.g
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,7 @@ parameter returns [Parameter parameter]
{ fp.setType(new FunctionModifier($FUNCTION_MODIFIER));
$parameter=fp; }
| VALUE_MODIFIER
{ fp.setType(new ValueModifier($VALUE_MODIFIER));
$parameter=fp; }
{ vp.setType(new ValueModifier($VALUE_MODIFIER)); }
)
memberName
{ vp.setIdentifier($memberName.identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,6 @@ public void visit(Tree.Parameter that) {
}*/
}
}
if (that.getType() instanceof Tree.LocalModifier &&
!(that instanceof Tree.InitializerParameter)) {
that.getType().setTypeModel(unit.getAnythingDeclaration().getType());
that.getType().addError("parameter may not have inferred type");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,22 @@ private void refine(Method sm, Tree.BaseMemberExpression bme,
super.visit(that);
Tree.Type type = that.getType();
Tree.DefaultArgument da = that.getDefaultArgument();
Parameter p = that.getDeclarationModel();
if (da!=null && type!=null) {
Tree.SpecifierExpression se = da.getSpecifierExpression();
checkType(type.getTypeModel(), that.getDeclarationModel().getName(), se, 2100);
checkType(type.getTypeModel(), p.getName(), se, 2100);
}
if (type instanceof Tree.LocalModifier &&
!(that instanceof Tree.InitializerParameter)) {
type.setTypeModel(new UnknownType(unit).getType());
if (!dynamic) {
type.addError("parameter may not have inferred type: " +
p.getName());
}
else if (p.getDeclaration().isShared()) {
type.addError("shared parameter may not have inferred type: " +
p.getName());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ else if (!(type.getDeclaration() instanceof ClassOrInterface)) {
@Override
public void visit(Tree.ValueParameterDeclaration that) {
super.visit(that);
if (that.getType() instanceof Tree.LocalModifier) {
if (that instanceof Tree.InitializerParameter) {
//i.e. an attribute initializer parameter
ValueParameter d = that.getDeclarationModel();
Declaration a = that.getScope().getDirectMember(d.getName(), null, false);
Expand Down

0 comments on commit 5d49391

Please sign in to comment.