use of org.eclipse.ceylon.model.typechecker.model.Function in project ceylon by eclipse.
the class AnnotationVisitor method visit.
@Override
public void visit(Tree.Constructor that) {
super.visit(that);
Function f = that.getDeclarationModel();
Unit unit = that.getUnit();
checkAnnotations(that.getAnnotationList(), unit.getCallableConstructorDeclarationType(), unit.getConstructorMetatype(f.getTypedReference()), that);
}
use of org.eclipse.ceylon.model.typechecker.model.Function in project ceylon by eclipse.
the class ExpressionVisitor method visitGenericQualifiedMemberReference.
private void visitGenericQualifiedMemberReference(Tree.QualifiedMemberExpression that, Type receiverType, TypedDeclaration member) {
if (member instanceof Function && member.isParameterized()) {
Function generic = (Function) member;
Scope scope = that.getScope();
TypedReference target = receiverType.getTypedMember(member, NO_TYPE_ARGS);
that.setTarget(target);
Type functionType = genericFunctionType(generic, scope, member, target, unit);
that.setTypeModel(functionType);
checkNotJvm(that, "type functions are not supported on the JVM: '" + member.getName(unit) + "' is generic (specify explicit type arguments)");
}
}
use of org.eclipse.ceylon.model.typechecker.model.Function in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.FunctionalParameterDeclaration that) {
Parameter p = new Parameter();
p.setDeclaration(declaration);
p.setDefaulted(getSpecifier(that) != null);
Tree.TypedDeclaration td = that.getTypedDeclaration();
Tree.Type type = td.getType();
p.setDeclaredAnything(type instanceof Tree.VoidModifier);
that.setParameterModel(p);
super.visit(that);
Function m = (Function) td.getDeclarationModel();
p.setModel(m);
p.setName(m.getName());
m.setInitializerParameter(p);
parameterList.getParameters().add(p);
if (type instanceof Tree.SequencedType) {
type.addError("functional parameter type may not be variadic");
}
if (m.isFormal()) {
that.addError("parameter may not be annotated 'formal'", 1312);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Function in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.FunctionArgument that) {
Tree.Type type = that.getType();
final Function f = new Function();
f.setName("anonymous#" + fid++);
f.setAnonymous(true);
if (type.getToken() != null) {
f.setDeclaredVoid(type instanceof Tree.VoidModifier);
} else {
Tree.Block block = that.getBlock();
if (block != null) {
f.setDeclaredVoid(true);
new Visitor() {
@Override
public void visit(Tree.Declaration that) {
}
@Override
public void visit(Tree.TypedArgument that) {
}
@Override
public void visit(Tree.ObjectExpression that) {
}
@Override
public void visit(Tree.FunctionArgument that) {
}
@Override
public void visit(Tree.Return that) {
if (that.getExpression() != null) {
f.setDeclaredVoid(false);
}
super.visit(that);
}
}.visit(block);
}
}
that.setDeclarationModel(f);
visitArgument(that, f);
Scope o = enterScope(f);
Declaration d = beginDeclaration(f);
super.visit(that);
endDeclaration(d);
exitScope(o);
setParameterLists(f, that.getParameterLists(), that);
}
use of org.eclipse.ceylon.model.typechecker.model.Function in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.AnyMethod that) {
Function m = new Function();
that.setDeclarationModel(m);
visitDeclaration(that, m);
Scope o = enterScope(m);
super.visit(that);
exitScope(o);
setParameterLists(m, that.getParameterLists(), that);
Tree.Type type = that.getType();
m.setDeclaredVoid(type instanceof Tree.VoidModifier);
if (type instanceof Tree.ValueModifier) {
type.addError("functions may not be declared using the keyword value");
}
if (type instanceof Tree.DynamicModifier) {
m.setDynamicallyTyped(true);
}
}
Aggregations