Do not try to load Java classes from incorrect packages
#KT-11474 Fixed
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/javaSrcWrongPackage.kt
|
||||||
|
$TESTDATA_DIR$/javaSrcWrongPackage
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fun test(): A.Nested = A().nested()
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/javaSrcWrongPackage.kt:1:13: error: unresolved reference: A
|
||||||
|
fun test(): A.Nested = A().nested()
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/javaSrcWrongPackage.kt:1:24: error: unresolved reference: A
|
||||||
|
fun test(): A.Nested = A().nested()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
public Nested nested() {
|
||||||
|
return new Nested();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Nested {}
|
||||||
|
}
|
||||||
@@ -218,6 +218,12 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaSrcWrongPackage.args")
|
||||||
|
public void testJavaSrcWrongPackage() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/javaSrcWrongPackage.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jvm8Target.args")
|
@TestMetadata("jvm8Target.args")
|
||||||
public void testJvm8Target() throws Exception {
|
public void testJvm8Target() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
|
||||||
|
|||||||
+5
-7
@@ -80,13 +80,11 @@ class LazyJavaPackageScope(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val actualFqName = javaClass?.fqName
|
||||||
val javaClassFqName = javaClass?.fqName ?: return@classByRequest null
|
if (actualFqName == null || actualFqName.isRoot || actualFqName.parent() != ownerDescriptor.fqName)
|
||||||
assert(!javaClassFqName.isRoot && javaClassFqName.parent() == ownerDescriptor.fqName) {
|
null
|
||||||
"Java class by request $requestClassId should be contained in package ${ownerDescriptor.fqName}, but it's fq-name: $javaClassFqName"
|
else
|
||||||
}
|
LazyJavaClassDescriptor(c, ownerDescriptor, javaClass)
|
||||||
|
|
||||||
LazyJavaClassDescriptor(c, ownerDescriptor, javaClass)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user