use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class TypeHierarchyVisitor method visit.
@Override
public void visit(Tree.ObjectExpression that) {
super.visit(that);
Class anonymousClass = that.getAnonymousClass();
// an object definition is always concrete
List<Type> orderedTypes = sortDAGAndBuildMetadata(anonymousClass, that);
checkForFormalsNotImplemented(that, orderedTypes, anonymousClass);
checkForDoubleMemberInheritanceNotOverridden(that, orderedTypes, anonymousClass);
checkForDoubleMemberInheritanceWoCommonAncestor(that, orderedTypes, anonymousClass);
validateMemberRefinement(that, anonymousClass);
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class TypeHierarchyVisitor method visit.
@Override
public void visit(Tree.ObjectDefinition that) {
super.visit(that);
Value value = that.getDeclarationModel();
Class anonymousClass = that.getAnonymousClass();
// an object definition is always concrete
List<Type> orderedTypes = sortDAGAndBuildMetadata(value.getTypeDeclaration(), that);
checkForFormalsNotImplemented(that, orderedTypes, anonymousClass);
checkForDoubleMemberInheritanceNotOverridden(that, orderedTypes, anonymousClass);
checkForDoubleMemberInheritanceWoCommonAncestor(that, orderedTypes, anonymousClass);
validateMemberRefinement(that, anonymousClass);
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class TypeVisitor method visit.
@Override
public void visit(Tree.SequenceType that) {
super.visit(that);
Tree.StaticType elementType = that.getElementType();
Tree.NaturalLiteral length = that.getLength();
Type et = elementType.getTypeModel();
if (et != null) {
Type t;
if (length == null) {
t = unit.getSequentialType(et);
} else {
final int len;
try {
len = parseInt(length.getText());
} catch (NumberFormatException nfe) {
length.addError("must be a positive decimal integer");
return;
}
if (len < 1) {
length.addError("must be positive");
return;
}
if (len > 1000) {
length.addError("may not be greater than 1000");
return;
}
Class td = unit.getTupleDeclaration();
t = unit.getEmptyType();
for (int i = 0; i < len; i++) {
t = appliedType(td, et, et, t);
}
}
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class TypeVisitor method visit.
/* private boolean hasSharedConstructors(Class cd) {
for (Declaration m: cd.getMembers()) {
if (m instanceof Constructor &&
m.isShared()) {
return true;
}
}
return false;
}*/
@Override
public void visit(Tree.InterfaceDefinition that) {
Interface id = that.getDeclarationModel();
id.setExtendedType(null);
id.getSatisfiedTypes().clear();
Class od = unit.getObjectDeclaration();
if (od != null) {
id.setExtendedType(od.getType());
}
super.visit(that);
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class TypeVisitor method visit.
@Override
public void visit(Tree.SatisfiedTypes that) {
super.visit(that);
TypeDeclaration td = (TypeDeclaration) that.getScope();
if (td.isAlias()) {
return;
}
List<Tree.StaticType> types = that.getTypes();
List<Type> list = new ArrayList<Type>(types.size());
if (types.isEmpty()) {
that.addError("missing types in satisfies");
}
boolean foundTypeParam = false;
boolean foundClass = false;
boolean foundInterface = false;
for (Tree.StaticType st : types) {
inheritedType(st);
Type type = st.getTypeModel();
if (type != null) {
TypeDeclaration std = type.getDeclaration();
if (std != null && !(std instanceof UnknownType)) {
if (std == td) {
// unnecessary, handled by SupertypeVisitor
// st.addError("directly extends itself: '" +
// td.getName() + "'");
} else if (std instanceof NothingType) {
st.addError("satisfies the bottom type 'Nothing'");
} else if (std instanceof TypeAlias) {
st.addError("satisfies a type alias: '" + type.getDeclaration().getName(unit) + "'");
} else if (std instanceof Constructor) {
// nothing to do
} else if (td instanceof TypeParameter) {
if (foundTypeParam) {
st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
} else if (std instanceof TypeParameter) {
if (foundClass || foundInterface) {
st.addUnsupportedError("type parameter upper bounds are not yet supported in combination with other bounds");
}
foundTypeParam = true;
list.add(type);
} else if (std instanceof Class) {
if (foundClass) {
st.addUnsupportedError("multiple class upper bounds are not yet supported");
}
foundClass = true;
list.add(type);
} else if (std instanceof Interface) {
foundInterface = true;
list.add(type);
} else {
st.addError("upper bound must be a class, interface, or type parameter");
}
} else {
if (std instanceof TypeParameter) {
st.addError("directly satisfies type parameter: '" + std.getName(unit) + "'");
} else if (std instanceof Class) {
st.addError("satisfies a class: '" + std.getName(unit) + "'");
} else if (std instanceof Interface) {
if (td.isDynamic() && !std.isDynamic()) {
st.addError("dynamic interface satisfies a non-dynamic interface: '" + std.getName(unit) + "'");
} else {
list.add(type);
}
} else {
st.addError("satisfied type must be an interface");
}
}
}
}
}
td.setSatisfiedTypes(list);
}
Aggregations