Fix a bug where kotlin common classes were seen as missing dependencies
When kotlin referred to them through java signatures Java resolver ignores expect classes #KT-24185 Fixed
This commit is contained in:
+2
-1
@@ -29,7 +29,8 @@ abstract class AbstractJavaResolverCache(private val resolveSession: ResolveSess
|
||||
protected val trace: BindingTrace get() = resolveSession.trace
|
||||
|
||||
override fun getClassResolvedFromSource(fqName: FqName): ClassDescriptor? {
|
||||
return trace.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe()) ?: findInPackageFragments(fqName)
|
||||
return trace.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe())?.takeUnless { it.isExpect }
|
||||
?: findInPackageFragments(fqName)
|
||||
}
|
||||
|
||||
private fun findInPackageFragments(fullFqName: FqName): ClassDescriptor? {
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ internal class ProjectResolutionFacade(
|
||||
packagePartProviderFactory = { IDEPackagePartProvider(it.moduleContentScope) },
|
||||
moduleByJavaClass = { javaClass: JavaClass ->
|
||||
val psiClass = (javaClass as JavaClassImpl).psi
|
||||
psiClass.getNullableModuleInfo()
|
||||
psiClass.getPlatformModuleInfo(JvmPlatform)?.platformModule ?: psiClass.getNullableModuleInfo()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package common
|
||||
|
||||
class A<T1, T2>(val t1: T1, val t2: T2)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package j1;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static A<String, String> returnA() {
|
||||
return new A<String, String>("", "");
|
||||
}
|
||||
|
||||
public static void acceptA(A<String, String> a) {
|
||||
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package j1
|
||||
|
||||
fun j() {
|
||||
Use.acceptA(Use.returnA())
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package j2;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static A<String, String> returnA() {
|
||||
return new A<String, String>("", "");
|
||||
}
|
||||
|
||||
public static void acceptA(A<String, String> a) {
|
||||
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package j2
|
||||
|
||||
fun j() {
|
||||
Use.acceptA(Use.returnA())
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package common
|
||||
|
||||
expect class A
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package j1;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static void use() {
|
||||
A a = new A();
|
||||
a.id1();
|
||||
}
|
||||
|
||||
public static void acceptA(A a) {
|
||||
|
||||
}
|
||||
|
||||
public static A returnA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package common
|
||||
|
||||
actual class A {
|
||||
fun id1() {}
|
||||
}
|
||||
|
||||
|
||||
fun use() {
|
||||
j2.Use.acceptA(j2.Use.returnA())
|
||||
j2.Use.returnA().id2()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package j2;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static void use() {
|
||||
A a = new A();
|
||||
a.id2();
|
||||
}
|
||||
|
||||
public static void acceptA(A a) {
|
||||
|
||||
}
|
||||
|
||||
public static A returnA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package common
|
||||
|
||||
actual class A {
|
||||
fun id2() {}
|
||||
}
|
||||
|
||||
|
||||
fun use() {
|
||||
j2.Use.acceptA(j2.Use.returnA())
|
||||
j2.Use.returnA().id2()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package j;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static void use(A a) {
|
||||
a.id2();
|
||||
}
|
||||
|
||||
public static void acceptA(A a) {
|
||||
|
||||
}
|
||||
|
||||
public static A returnA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package b
|
||||
|
||||
import common.A
|
||||
|
||||
fun use(a: A) {
|
||||
a.id2()
|
||||
j.Use.acceptA(j.Use.returnA())
|
||||
val a2: A = j.Use.returnA()
|
||||
a2.id2()
|
||||
j.Use.returnA().id2()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package j;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static void use(A a) {
|
||||
a.id1();
|
||||
}
|
||||
|
||||
public static void acceptA(A a) {
|
||||
|
||||
}
|
||||
|
||||
public static A returnA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package c
|
||||
|
||||
import common.A
|
||||
|
||||
fun use(a: A) {
|
||||
// errors happen when common module part appears before platform part in dependencies list
|
||||
// this is incorrect behaviour but doesn't seem to lead to user facing bugs atm
|
||||
a.<error>id1</error>()
|
||||
val a2: A = j.Use.returnA()
|
||||
a2.<error>id1</error>()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package j;
|
||||
|
||||
import common.A;
|
||||
|
||||
public class Use {
|
||||
public static void use(A a) {
|
||||
a.id1();
|
||||
}
|
||||
|
||||
public static void acceptA(A a) {
|
||||
|
||||
}
|
||||
|
||||
public static A returnA() {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package c
|
||||
|
||||
import common.A
|
||||
|
||||
fun use(a: A) {
|
||||
a.id1()
|
||||
j.Use.acceptA(j.Use.returnA())
|
||||
j.Use.returnA().id1()
|
||||
val a2: A = j.Use.returnA()
|
||||
a2.id1()
|
||||
}
|
||||
Generated
+10
@@ -99,6 +99,16 @@ public class MultiPlatformHighlightingTestGenerated extends AbstractMultiPlatfor
|
||||
runTest("idea/testData/multiModuleHighlighting/multiplatform/javaUsesPlatformFacade/");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmKotlinReferencesCommonKotlinThroughJava")
|
||||
public void testJvmKotlinReferencesCommonKotlinThroughJava() throws Exception {
|
||||
runTest("idea/testData/multiModuleHighlighting/multiplatform/jvmKotlinReferencesCommonKotlinThroughJava/");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmKotlinReferencesCommonKotlinThroughJavaDifferentJvmImpls")
|
||||
public void testJvmKotlinReferencesCommonKotlinThroughJavaDifferentJvmImpls() throws Exception {
|
||||
runTest("idea/testData/multiModuleHighlighting/multiplatform/jvmKotlinReferencesCommonKotlinThroughJavaDifferentJvmImpls/");
|
||||
}
|
||||
|
||||
@TestMetadata("multifileFacade")
|
||||
public void testMultifileFacade() throws Exception {
|
||||
runTest("idea/testData/multiModuleHighlighting/multiplatform/multifileFacade/");
|
||||
|
||||
Reference in New Issue
Block a user