use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class AnalyzerUtil method getTupleType.
public static Type getTupleType(List<Tree.PositionalArgument> es, Unit unit, boolean requireSequential) {
Type result = unit.getEmptyType();
Type ut = unit.getNothingType();
Class td = unit.getTupleDeclaration();
Interface id = unit.getIterableDeclaration();
for (int i = es.size() - 1; i >= 0; i--) {
Tree.PositionalArgument a = es.get(i);
Type t = a.getTypeModel();
if (t != null) {
// unit.denotableType(t);
Type et = t;
if (a instanceof Tree.SpreadArgument) {
/*if (requireSequential) {
checkSpreadArgumentSequential((Tree.SpreadArgument) a, et);
}*/
if (unit.isIterableType(et)) {
ut = unit.getIteratedType(et);
result = spreadType(et, unit, requireSequential);
} else if (unit.isJavaIterableType(et)) {
ut = unit.getJavaIteratedType(et);
result = unit.getSequentialType(ut);
} else if (unit.isJavaArrayType(et)) {
ut = unit.getJavaArrayElementType(et);
result = unit.getSequentialType(ut);
} else {
result = unit.getUnknownType();
}
} else if (a instanceof Tree.Comprehension) {
ut = et;
Tree.Comprehension c = (Tree.Comprehension) a;
Tree.InitialComprehensionClause icc = c.getInitialComprehensionClause();
result = icc.getPossiblyEmpty() ? unit.getSequentialType(et) : unit.getSequenceType(et);
if (!requireSequential) {
Type it = appliedType(id, et, icc.getFirstTypeModel());
result = intersectionType(result, it, unit);
}
} else {
ut = unionType(ut, et, unit);
result = appliedType(td, ut, et, result);
}
}
}
return result;
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class AnnotationVisitor method visit.
@Override
public void visit(Tree.AnyClass that) {
super.visit(that);
Class c = that.getDeclarationModel();
if (c.isAnnotation()) {
checkAnnotationType(that, c);
}
Unit unit = that.getUnit();
checkAnnotations(that.getAnnotationList(), unit.getClassDeclarationType(c), unit.getClassMetatype(c.getType()), that);
checkServiceAnnotations(c, that.getAnnotationList());
}
use of org.eclipse.ceylon.model.typechecker.model.Class 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.Class in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.ObjectExpression that) {
Class c = new Class();
c.setName("anonymous#" + fid++);
c.setNamed(false);
defaultExtendedToBasic(c);
c.setAnonymous(true);
that.setAnonymousClass(c);
visitArgument(that, c);
Scope o = enterScope(c);
super.visit(that);
exitScope(o);
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.ObjectArgument that) {
Class c = new Class();
defaultExtendedToBasic(c);
c.setAnonymous(true);
that.setAnonymousClass(c);
visitArgument(that, c);
Value v = new Value();
that.setDeclarationModel(v);
visitArgument(that, v);
Type t = c.getType();
that.getType().setTypeModel(t);
v.setType(t);
Scope o = enterScope(c);
super.visit(that);
exitScope(o);
}
Aggregations