TypeConstraint#union: smarter merge of supertypes

union("is X, Y; not SubX", "is SubX, Y") now produces "is X, Y"; before it was "is Y".
Fixes IDEA-184153 Smart-cast completion fails
This commit is contained in:
Tagir Valeev
2017-12-22 12:42:40 +07:00
parent 9c64404925
commit 390cec4927
3 changed files with 43 additions and 12 deletions
@@ -0,0 +1,25 @@
import java.math.BigInteger;
import java.util.function.Function;
class Test {
interface X {
void methodFromX();
void methodFromX2();
}
interface Y {
void methodFromY();
void methodFromY2();
}
interface Z extends X {}
void test(Object obj) {
if(obj instanceof Z && Math.random() > 0.5) {
return;
}
if(obj instanceof X && obj instanceof Y) {
obj.method<caret>
}
}
}