[java-psi] Do not resolve super() call to Object() constructor when superclass is not resolved

Needed for incomplete project model.

GitOrigin-RevId: 2acbba54f4fd50fb3261601f1cb66175d7f19da6
This commit is contained in:
Tagir Valeev
2024-06-07 16:43:12 +00:00
committed by intellij-monorepo-bot
parent 5218db2d69
commit 7fe1b165a4
3 changed files with 14 additions and 1 deletions
@@ -2,6 +2,7 @@
package com.intellij.psi.scope.util;
import com.intellij.lang.jvm.types.JvmReferenceType;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.util.Comparing;
@@ -21,6 +22,7 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -247,7 +249,8 @@ public final class PsiScopesUtil {
throw new MethodProcessorSetupFailedException("Can't resolve class for super expression");
}
final PsiClass superClass = aClass.getSuperClass();
JvmReferenceType type = aClass.getSuperClassType();
final PsiClass superClass = type == null ? null : ObjectUtils.tryCast(type.resolve(), PsiClass.class);
if (superClass != null) {
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
PsiClass runSuper = superClass;
@@ -0,0 +1,8 @@
import <info descr="Not resolved until the project is fully loaded">com</info>.<info descr="Not resolved until the project is fully loaded">example</info>.<info descr="Not resolved until the project is fully loaded">Super</info>;
class Sub extends <info descr="Not resolved until the project is fully loaded">Super</info> {
Sub() {
<info descr="Not resolved until the project is fully loaded">super</info>(123);
}
}
@@ -37,4 +37,6 @@ public final class IncompleteModelHighlightingTest extends LightDaemonAnalyzerTe
public void testInferenceFailure() { doTest(); }
public void testIncompleteRecursiveParameters() { doTest(); }
public void testSuperCall() { doTest(); }
}