}
}
if(t1 instanceof FunctionType
&& t2 instanceof FunctionType && t1 != t2) {
FunctionType f1 = (FunctionType) t1;
FunctionType f2 = (FunctionType) t2;
Type lub = f1.lub(f2);
Type glb = f1.glb(f2);
// System.out.println("Checking subtyping: " + f1 + " and " + f2 + "; lub and glb: " + lub + ", " + glb);
if(f1.isSubtypeOf(f2)) {
assertTrue(f1.getReturnType().isSubtypeOf(f2.getReturnType()));
assertTrue(f2.getArgumentTypes().isSubtypeOf(f1.getArgumentTypes()));
}
if(f2.isSubtypeOf(f1)) {
assertTrue(f2.getReturnType().isSubtypeOf(f1.getReturnType()));
assertTrue(f1.getArgumentTypes().isSubtypeOf(f2.getArgumentTypes()));
}
if(lub instanceof FunctionType) {
FunctionType flub = (FunctionType) lub;
assertTrue(f1.getReturnType().isSubtypeOf(flub.getReturnType()));
assertTrue(flub.getArgumentTypes().isSubtypeOf(f1.getArgumentTypes()));
assertTrue(f2.getReturnType().isSubtypeOf(flub.getReturnType()));
assertTrue(flub.getArgumentTypes().isSubtypeOf(f2.getArgumentTypes()));
}
if(glb instanceof FunctionType) {
FunctionType fglb = (FunctionType) glb;
assertTrue(fglb.getReturnType().isSubtypeOf(f1.getReturnType()));
assertTrue(f1.getArgumentTypes().isSubtypeOf(fglb.getArgumentTypes()));
assertTrue(fglb.getReturnType().isSubtypeOf(f2.getReturnType()));
assertTrue(f2.getArgumentTypes().isSubtypeOf(fglb.getArgumentTypes()));
}
}
}
}