|
|
@@ -105,6 +105,8 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
|
|
|
}
|
|
|
|
|
|
protected void assertType(Type type1, String msg, Type... types) {
|
|
|
+ if (type1 == null)
|
|
|
+ return;
|
|
|
boolean same = false;
|
|
|
for (Type type : types) {
|
|
|
if (typeSystem.isSame(type1, type)) {
|
|
|
@@ -116,19 +118,35 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected void assertNotType(Type type1, String msg, Type... types) {
|
|
|
+ if(type1 == null)
|
|
|
+ return;
|
|
|
+ for (Type type : types) {
|
|
|
+ if (typeSystem.isSame(type1, type)) {
|
|
|
+ error(msg != null ? msg : "Expected one of " + Arrays.toString(types) + " but was " + type1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected void assertSame(Type type1, Type type2, String msg) {
|
|
|
+ if(type1 == null || type2 == null)
|
|
|
+ return;
|
|
|
if (!typeSystem.isSame(type1, type2)) {
|
|
|
error(msg != null ? msg : "Types not the same : " + type1 + " and " + type2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void assertCompatibleType(Type type1, Type type2, String msg) {
|
|
|
+ if(type1 == null || type2 == null)
|
|
|
+ return;
|
|
|
if (!typeSystem.haveCommonType(type1, type2)) {
|
|
|
error(msg != null ? msg : "Incompatible types " + type1 + " and " + type2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void assertIsSuperType(Type subType, Type superType, String msg) {
|
|
|
+ if(subType == null || superType == null)
|
|
|
+ return;
|
|
|
if (!typeSystem.isSuperType(subType, superType)) {
|
|
|
error(msg != null ? msg : "Incompatible types " + subType + " and " + superType);
|
|
|
}
|