mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
disjunction type equals/hashCode, essential for new inference (IDEA-140150)
This commit is contained in:
@@ -148,4 +148,24 @@ public class PsiDisjunctionType extends PsiType.Stub {
|
||||
return new PsiType[]{lub};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myTypes.get(0).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final PsiDisjunctionType that = (PsiDisjunctionType)o;
|
||||
if (that.myTypes.size() != myTypes.size()) return false;
|
||||
|
||||
for (int i = 0; i < myTypes.size(); i++) {
|
||||
if (!myTypes.get(i).equals(that.myTypes.get(i))) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
class Main {
|
||||
public static class Either<A, B> {
|
||||
final public Optional<A> _1;
|
||||
final public Optional<B> _2;
|
||||
|
||||
private Either(Optional<A> _1, Optional<B> _2) {
|
||||
this._1 = _1;
|
||||
this._2 = _2;
|
||||
}
|
||||
|
||||
public static <A, B> Either<A, B> _2(B value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Either<String, Exception> test1() {
|
||||
try {
|
||||
new FileOutputStream("").write(1);
|
||||
return null;
|
||||
} catch (NullPointerException | IOException e) {
|
||||
return Either._2(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -275,6 +275,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDisjunctionTypeEquality() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user