Permalink
Browse files

functions with dynamically typed params #600

  • Loading branch information...
gavinking committed Feb 13, 2013
1 parent ec0c077 commit 5d49391ba461d4062c421d5ffc2cf1122452970c
View
@@ -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);
@@ -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
@@ -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());
+ }
}
}
@@ -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);

0 comments on commit 5d49391

Please sign in to comment.