use of org.eclipse.ceylon.model.typechecker.model.DecidabilityException in project ceylon by eclipse.
the class SupertypeVisitor method checkForUndecidability.
private void checkForUndecidability(Tree.ExtendedType etn, Tree.SatisfiedTypes stn, TypeDeclaration type, Tree.TypeDeclaration that) {
boolean errors = false;
if (stn != null) {
for (Tree.StaticType st : stn.getTypes()) {
Type t = st.getTypeModel();
if (t != null) {
TypeDeclaration td = t.getDeclaration();
if (!(td instanceof UnknownType) && !(td instanceof TypeAlias)) {
if (td == type) {
brokenSatisfiedType(type, st, null);
errors = true;
} else {
List<TypeDeclaration> list = t.isRecursiveRawTypeDefinition(singleton(type));
if (!list.isEmpty()) {
brokenSatisfiedType(type, st, list);
errors = true;
}
}
}
}
}
}
if (etn != null) {
Tree.StaticType et = etn.getType();
if (et != null) {
Type t = et.getTypeModel();
if (t != null) {
TypeDeclaration td = t.getDeclaration();
if (!(td instanceof UnknownType) && !(td instanceof TypeAlias)) {
if (td == type) {
brokenExtendedType(type, et, null);
errors = true;
} else {
List<TypeDeclaration> list = t.isRecursiveRawTypeDefinition(singleton(type));
if (!list.isEmpty()) {
brokenExtendedType(type, et, list);
errors = true;
}
}
}
}
}
}
if (!errors) {
Unit unit = type.getUnit();
List<Type> list = new ArrayList<Type>();
try {
List<Type> supertypes = type.getType().getSupertypes();
for (Type st : supertypes) {
addToIntersection(list, st, unit);
}
// probably unnecessary - if it were
// going to blow up, it would have
// already blown up in addToIntersection()
canonicalIntersection(list, unit);
} catch (DecidabilityException re) {
brokenHierarchy(type, that, unit);
return;
}
try {
type.getType().getUnionOfCases();
} catch (DecidabilityException re) {
brokenSelfType(type, that);
}
if (stn != null) {
for (Tree.StaticType st : stn.getTypes()) {
Type t = st.getTypeModel();
if (t != null) {
if (checkSupertypeVariance(t, type, st)) {
type.getSatisfiedTypes().remove(t);
type.clearProducedTypeCache();
}
}
}
}
if (etn != null) {
Tree.StaticType et = etn.getType();
if (et != null) {
Type t = et.getTypeModel();
if (t != null) {
if (checkSupertypeVariance(t, type, et)) {
type.setExtendedType(unit.getBasicType());
type.clearProducedTypeCache();
}
}
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.DecidabilityException in project ceylon by eclipse.
the class DefaultTypeArgVisitor method visit.
@Override
public void visit(Tree.TypeParameterDeclaration that) {
Tree.TypeSpecifier ts = that.getTypeSpecifier();
if (ts != null) {
TypeParameter tp = that.getDeclarationModel();
Declaration dec = tp.getDeclaration();
Type dta = tp.getDefaultTypeArgument();
if (dta != null) {
try {
if (dta.involvesDeclaration(dec)) {
tp.setDefaultTypeArgument(null);
}
} catch (DecidabilityException re) {
ts.addError("undecidable default type argument");
tp.setDefaultTypeArgument(null);
}
}
}
super.visit(that);
}
Aggregations