use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class ExpressionVisitor method visitGenericQualifiedTypeReference.
private void visitGenericQualifiedTypeReference(Tree.QualifiedTypeExpression that, Type outerType, TypeDeclaration type) {
if (type instanceof Class && type.isParameterized()) {
Class generic = (Class) type;
Scope scope = that.getScope();
Type target = outerType.getTypeMember(type, typeParametersAsArgList(generic));
that.setTarget(target);
Type functionType = genericFunctionType(generic, scope, type, target, unit);
that.setTypeModel(functionType);
checkNotJvm(that, "type functions are not supported on the JVM: '" + type.getName(unit) + "' is generic (specify explicit type arguments)");
}
}
use of org.eclipse.ceylon.model.typechecker.model.Scope 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.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.Enumerated that) {
Constructor e = new Constructor();
that.setEnumerated(e);
visitDeclaration(that, e, false);
Type at;
if (scope instanceof Class) {
Class clazz = (Class) scope;
Type ot = clazz.getType();
e.setExtendedType(ot);
at = e.appliedType(ot, NO_TYPE_ARGS);
clazz.setEnumerated(true);
if (clazz.isAnonymous()) {
that.addError("anonymous class may not have a value constructor: '" + clazz.getName() + "' is an anonymous class");
} else if (clazz.isAbstract()) {
that.addError("abstract class may not have a value constructor: '" + clazz.getName() + "' is abstract");
} else if (!clazz.getTypeParameters().isEmpty()) {
that.addError("generic class may not have a value constructor: '" + clazz.getName() + "' is generic");
} else if (scope.getContainer() instanceof Interface) {
that.addError("class nested inside an interface may not have a value constructor: '" + clazz.getName() + "' belongs to an interface");
}
} else {
at = null;
that.addError("value constructor declaration must occur directly in the body of a class");
}
Value v = new Value();
v.setType(at);
that.setDeclarationModel(v);
visitDeclaration(that, v);
Scope o = enterScope(e);
super.visit(that);
exitScope(o);
v.setImplemented(that.getBlock() != null);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.SwitchStatement that) {
ControlBlock cb = new ControlBlock();
cb.setId(id++);
that.setControlBlock(cb);
visitElement(that, cb);
Scope o = enterScope(cb);
super.visit(that);
exitScope(o);
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.BaseType that) {
super.visit(that);
final Scope scope = that.getScope();
final String name = name(that.getIdentifier());
if (inExtends) {
final Tree.TypeArgumentList tal = that.getTypeArgumentList();
final boolean packageQualified = that.getPackageQualified();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
return packageQualified ? getPackageTypeDeclaration(name, null, false, unit) : getTypeDeclaration(scope, name, null, false, unit);
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getTypeArgumentMap(dec, null, AnalyzerUtil.getTypeArguments(tal, null, tps));
}
@Override
public Map<TypeParameter, SiteVariance> initVarianceOverrides() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getVarianceMap(dec, null, AnalyzerUtil.getVariances(tal, tps));
}
};
that.setTypeModel(t);
}
}
Aggregations