[FIR] Don't create generated nested classifier scope for non-source classes
^KT-57626 Fixed
This commit is contained in:
committed by
Space Team
parent
ea6651445c
commit
fb97f4db87
+5
-2
@@ -91,11 +91,14 @@ class FirDeclaredMemberScopeProvider(val useSiteSession: FirSession) : FirSessio
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createNestedClassifierScope(klass: FirClass): FirNestedClassifierScope? {
|
private fun createNestedClassifierScope(klass: FirClass): FirNestedClassifierScope? {
|
||||||
return if (klass.origin.generated) {
|
val origin = klass.origin
|
||||||
|
return if (origin.generated) {
|
||||||
FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass, baseScope = null)
|
FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass, baseScope = null)
|
||||||
} else {
|
} else {
|
||||||
val baseScope = FirNestedClassifierScopeImpl(klass, useSiteSession)
|
val baseScope = FirNestedClassifierScopeImpl(klass, useSiteSession)
|
||||||
val generatedScope = FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass, baseScope)
|
val generatedScope = runIf(origin.fromSource) {
|
||||||
|
FirGeneratedClassNestedClassifierScope.create(useSiteSession, klass, baseScope)
|
||||||
|
}
|
||||||
if (generatedScope != null) {
|
if (generatedScope != null) {
|
||||||
FirCompositeNestedClassifierScope(
|
FirCompositeNestedClassifierScope(
|
||||||
listOf(baseScope, generatedScope),
|
listOf(baseScope, generatedScope),
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// WITH_STDLIB
|
||||||
|
// ISSUE: KT-57626
|
||||||
|
|
||||||
|
// MODULE: lib
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class A(val s: String = "")
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class B(val a: A? = null)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val expectedB = B(A("OK"))
|
||||||
|
val json = Json.encodeToString(B.serializer(), expectedB)
|
||||||
|
if (json != """{"a":{"s":"OK"}}""") return "Fail: $json"
|
||||||
|
val actualB = Json.decodeFromString(B.serializer(), json)
|
||||||
|
if (expectedB != actualB) return "Fail: $actualB"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -177,6 +177,12 @@ public class SerializationFirLightTreeBlackBoxTestGenerated extends AbstractSeri
|
|||||||
runTest("plugins/kotlinx-serialization/testData/boxIr/serialInfo.kt");
|
runTest("plugins/kotlinx-serialization/testData/boxIr/serialInfo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("serializableFromAnotherModule.kt")
|
||||||
|
public void testSerializableFromAnotherModule() throws Exception {
|
||||||
|
runTest("plugins/kotlinx-serialization/testData/boxIr/serializableFromAnotherModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("serializableOnPropertyType.kt")
|
@TestMetadata("serializableOnPropertyType.kt")
|
||||||
public void testSerializableOnPropertyType() throws Exception {
|
public void testSerializableOnPropertyType() throws Exception {
|
||||||
|
|||||||
+6
@@ -175,6 +175,12 @@ public class SerializationIrBoxTestGenerated extends AbstractSerializationIrBoxT
|
|||||||
runTest("plugins/kotlinx-serialization/testData/boxIr/serialInfo.kt");
|
runTest("plugins/kotlinx-serialization/testData/boxIr/serialInfo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("serializableFromAnotherModule.kt")
|
||||||
|
public void testSerializableFromAnotherModule() throws Exception {
|
||||||
|
runTest("plugins/kotlinx-serialization/testData/boxIr/serializableFromAnotherModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("serializableOnPropertyType.kt")
|
@TestMetadata("serializableOnPropertyType.kt")
|
||||||
public void testSerializableOnPropertyType() throws Exception {
|
public void testSerializableOnPropertyType() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user