Fix searching serialized classes package contains multiple fragments
This commit is contained in:
+6
@@ -296,6 +296,12 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionReferencingClass")
|
||||||
|
public void testFunctionReferencingClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+6
@@ -296,6 +296,12 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionReferencingClass")
|
||||||
|
public void testFunctionReferencingClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
+2
-7
@@ -55,13 +55,8 @@ class ClassDeserializer(private val components: DeserializationComponents) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val fragments = components.packageFragmentProvider.getPackageFragments(classId.packageFqName)
|
val fragments = components.packageFragmentProvider.getPackageFragments(classId.packageFqName)
|
||||||
assert(fragments.size == 1) { "There should be exactly one package: $fragments, class id is $classId" }
|
val fragment = fragments.firstOrNull { it !is DeserializedPackageFragment || it.hasTopLevelClass(classId.shortClassName) }
|
||||||
|
?: return null
|
||||||
val fragment = fragments.single()
|
|
||||||
if (fragment is DeserializedPackageFragment) {
|
|
||||||
// Similarly, verify that the containing package has information about this class
|
|
||||||
if (!fragment.hasTopLevelClass(classId.shortClassName)) return null
|
|
||||||
}
|
|
||||||
|
|
||||||
components.createContext(
|
components.createContext(
|
||||||
fragment, nameResolver,
|
fragment, nameResolver,
|
||||||
|
|||||||
+7
-4
@@ -22,9 +22,12 @@ import org.jetbrains.kotlin.serialization.ClassDataWithSource
|
|||||||
|
|
||||||
class DeserializedClassDataFinder(private val packageFragmentProvider: PackageFragmentProvider) : ClassDataFinder {
|
class DeserializedClassDataFinder(private val packageFragmentProvider: PackageFragmentProvider) : ClassDataFinder {
|
||||||
override fun findClassData(classId: ClassId): ClassDataWithSource? {
|
override fun findClassData(classId: ClassId): ClassDataWithSource? {
|
||||||
val packageFragment =
|
val packageFragments = packageFragmentProvider.getPackageFragments(classId.packageFqName)
|
||||||
packageFragmentProvider.getPackageFragments(classId.packageFqName).singleOrNull()
|
for (fragment in packageFragments) {
|
||||||
as? DeserializedPackageFragment ?: return null
|
if (fragment !is DeserializedPackageFragment) continue
|
||||||
return packageFragment.classDataFinder.findClassData(classId)
|
|
||||||
|
fragment.classDataFinder.findClassData(classId)?.let { return it }
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -467,6 +467,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionReferencingClass")
|
||||||
|
public void testFunctionReferencingClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/functionReferencingClass/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("independentClasses")
|
@TestMetadata("independentClasses")
|
||||||
public void testIndependentClasses() throws Exception {
|
public void testIndependentClasses() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/independentClasses/");
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
class A(val x: Int)
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
================ Step #1 =================
|
||||||
|
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module/META-INF/module.kotlin_module
|
||||||
|
out/production/module/UseAKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/useA.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fun useA(a: A) { a.x }
|
||||||
@@ -3497,6 +3497,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("classReferencingClass.kt")
|
||||||
|
public void testClassReferencingClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/classReferencingClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("coroutines.kt")
|
@TestMetadata("coroutines.kt")
|
||||||
public void testCoroutines() throws Exception {
|
public void testCoroutines() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/coroutines.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/coroutines.kt");
|
||||||
@@ -3515,6 +3521,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionReferencingClass.kt")
|
||||||
|
public void testFunctionReferencingClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/functionReferencingClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inline.kt")
|
@TestMetadata("inline.kt")
|
||||||
public void testInline() throws Exception {
|
public void testInline() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/inline.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/inline.kt");
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 1002
|
||||||
|
// FILE: A.kt
|
||||||
|
|
||||||
|
open class A {
|
||||||
|
open fun f(): Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
// RECOMPILE
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
override fun f(): Int = super.f() + 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: box.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val af = A().f()
|
||||||
|
if (af != 1) return "fail: result of 'A().f()' is '$af', but '1' was expected"
|
||||||
|
|
||||||
|
val bf = B().f()
|
||||||
|
if (bf != 3) return "fail: result of 'B().f()' is '$bf', but '3' was expected"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 995
|
||||||
|
// FILE: A.kt
|
||||||
|
|
||||||
|
open class A {
|
||||||
|
open fun f(): Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: useA.kt
|
||||||
|
// RECOMPILE
|
||||||
|
|
||||||
|
fun useA(a: A): Int = a.f()
|
||||||
|
fun useList(xs: List<Int>) {}
|
||||||
|
|
||||||
|
// FILE: box.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val result = useA(A())
|
||||||
|
if (result != 1) return "fail: result of 'useA(A())' is '$result', but '1' was expected"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user