mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
[java-dfa] Return PSI-type for ExactSubclass
We don't specify that getPsiType() returns exact type, it may return a supertype. On the other hand, some clients assume that it returns exact type when isExact is true, so this may cause surprises for them GitOrigin-RevId: 70165d6dadea07995dd0f1d6a456814b3970bad6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
072efa77e1
commit
78a77d064c
@@ -556,7 +556,7 @@ public final class CustomMethodHandlers {
|
||||
private static @NotNull DfType objectGetClass(DfaCallArguments arguments, DfaMemoryState state, DfaValueFactory factory, PsiMethod method) {
|
||||
DfaValue qualifier = arguments.myQualifier;
|
||||
TypeConstraint fact = TypeConstraint.fromDfType(state.getDfType(qualifier));
|
||||
if (fact instanceof TypeConstraint.Exact) {
|
||||
if (fact instanceof TypeConstraint.Exact && !(fact instanceof TypeConstraints.ExactSubclass)) {
|
||||
PsiType qualifierType = fact.getPsiType(factory.getProject());
|
||||
PsiType classType = method.getReturnType();
|
||||
if (classType != null && qualifierType != null) {
|
||||
|
||||
@@ -484,6 +484,12 @@ public final class TypeConstraints {
|
||||
return new ExactSubclass(myId, ContainerUtil.map2Array(mySupers, Exact.class, ex -> ex.convert(factory)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PsiType getPsiType(Project project) {
|
||||
PsiType[] types = StreamEx.of(mySupers).map(st -> st.getPsiType(project)).distinct().toArray(PsiType.EMPTY_ARRAY);
|
||||
return types.length == 0 ? null : PsiIntersectionType.createIntersection(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user