use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class InheritanceVisitor method visit.
@Override
public void visit(Tree.Enumerated that) {
super.visit(that);
Value v = that.getDeclarationModel();
Scope container = v.getContainer();
if (container instanceof Class) {
Class cl = (Class) container;
List<TypedDeclaration> caseValues = cl.getCaseValues();
if (caseValues != null && !caseValues.contains(v) && !cl.isAbstract()) {
that.addError("value constructor is not a case of enumerated class: '" + v.getName() + "' is not listed in the 'of' clause of '" + cl.getName() + "'");
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class LocalDeclarationVisitor method visit.
@Override
public void visit(Tree.ObjectDefinition that) {
visitLocalDecl(that);
// use the same qualifier for the object type
Class c = that.getAnonymousClass();
Value v = that.getDeclarationModel();
if (c != null && v != null) {
c.setQualifier(v.getQualifier());
}
Map<String, Integer> oldLocalNames = localNames;
localNames = new HashMap<String, Integer>();
super.visit(that);
localNames = oldLocalNames;
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class TypeArgumentInference method constrainInferredTypes.
private List<Type> constrainInferredTypes(List<TypeParameter> typeParameters, List<Type> inferredTypeArgs, Type qualifyingType, Declaration declaration) {
int size = inferredTypeArgs.size();
boolean found = false;
for (int i = 0; i < size; i++) {
TypeParameter tp = typeParameters.get(i);
// if (!tp.isCovariant()) {
List<Type> bounds = tp.getSatisfiedTypes();
if (!bounds.isEmpty()) {
found = true;
}
// }
}
if (found) {
Reference ref;
if (declaration instanceof Value) {
Value value = (Value) declaration;
if (value.getType().isTypeConstructor()) {
if (qualifyingType == null) {
ref = declaration.appliedReference(null, NO_TYPE_ARGS);
} else {
ref = qualifyingType.getTypedReference(declaration, NO_TYPE_ARGS);
}
TypeDeclaration dec = ref.getType().getDeclaration();
ref = dec.appliedReference(null, inferredTypeArgs);
} else {
return inferredTypeArgs;
}
} else {
if (qualifyingType == null) {
ref = declaration.appliedReference(null, inferredTypeArgs);
} else {
ref = qualifyingType.getTypedReference(declaration, inferredTypeArgs);
}
}
Map<TypeParameter, Type> args = ref.getTypeArguments();
ArrayList<Type> result = new ArrayList<Type>(size);
for (int i = 0; i < size; i++) {
TypeParameter tp = typeParameters.get(i);
Type arg = inferredTypeArgs.get(i);
Type constrainedArg = // tp.isCovariant() ? arg :
constrainInferredType(tp, arg, args);
result.add(constrainedArg);
}
return result;
} else {
return inferredTypeArgs;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value 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.Value in project ceylon by eclipse.
the class TypeVisitor method visit.
@Override
public void visit(Tree.AnyAttribute that) {
super.visit(that);
Tree.Type type = that.getType();
if (type instanceof Tree.SequencedType) {
Value v = (Value) that.getDeclarationModel();
Parameter p = v.getInitializerParameter();
if (p == null) {
type.addError("value is not a parameter, so may not be variadic: '" + v.getName() + "'");
} else {
p.setSequenced(true);
}
}
}
Aggregations