Fixed bug in TypeUtils.intersect().
For "Foo", "Foo?" it returned "{Foo}" instead of "Foo"
This commit is contained in:
@@ -149,6 +149,12 @@ public class TypeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// Don't add type if it is already present, to avoid trivial type intersections in result
|
||||
for (JetType other : resultingTypes) {
|
||||
if (typeChecker.equalTypes(other, type)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
resultingTypes.add(type);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,10 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void testIntersect() throws Exception {
|
||||
assertIntersection("Number", "Number?", "Hashable");
|
||||
assertIntersection("Number", "Hashable", "Number?");
|
||||
assertIntersection("Hashable", "Hashable?", "Hashable");
|
||||
|
||||
assertIntersection("Int?", "Int?", "Int?");
|
||||
assertIntersection("Int", "Int?", "Int");
|
||||
assertIntersection("Int", "Int", "Int?");
|
||||
|
||||
Reference in New Issue
Block a user