Fixed bug in TypeUtils.intersect().

For "Foo", "Foo?" it returned "{Foo}" instead of "Foo"
This commit is contained in:
Evgeny Gerashchenko
2012-11-01 20:21:45 +04:00
parent 45df349f16
commit 8365cee0b5
2 changed files with 10 additions and 0 deletions
@@ -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?");