[Kotlin][Java inference] Apply use site scope for j.l.Object

With KMP projects it's possible that a class can reside in a common
module with no JDK available. Trying to use class' resolve scope
for creating java.lang.Object type in this case will result in an
incorrect type. Use site scope from a type comes from a JVM module
which has a JDK available.

KTIJ-28461

GitOrigin-RevId: b19fe424ce4f7745e7f6aad7c5a34bb3912f5a56
This commit is contained in:
Pavel Kirpichenkov
2024-06-07 15:59:38 +03:00
committed by intellij-monorepo-bot
parent 1aa062a419
commit 9ea82d1a98
3 changed files with 3 additions and 3 deletions

View File

@@ -97,7 +97,7 @@ public final class GenericsUtil {
PsiClass[] supers = getLeastUpperClasses(aClass, bClass);
if (supers.length == 0) {
return PsiType.getJavaLangObject(manager, aClass.getResolveScope());
return PsiType.getJavaLangObject(manager, type1.getResolveScope());
}
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(manager.getProject());

View File

@@ -15,6 +15,6 @@ public class Ktij28461 {
}
public static void cstOfJavaPrimitiveAndCommonClass(CommonClass cc) {
jGeneric<error descr="'jGeneric(K, K)' in 'pack.Ktij28461' cannot be applied to '(int, pack.CommonClass)'">(1, cc)</error>;
jGeneric(1, cc);
}
}

View File

@@ -30,7 +30,7 @@ public class JavaReference {
cd.ktFunVarargGeneric(1, jc);
jd.ktFunVarargGeneric(1, "");
jd.ktFunVarargGeneric<error descr="'ktFunVarargGeneric(T...)' in 'pack.JvmVarArgDecl' cannot be applied to '(int, pack.CommonClassForVA)'">(1, cc)</error>; // Error is here.
jd.ktFunVarargGeneric(1, cc); // Error is here.
jd.ktFunVarargGeneric(1, jc);
}
}