[IR BE] Fix symbol remapping for IrField/IrProperty
- Use appropriate wrapped descriptor - Add test
This commit is contained in:
+9
-1
@@ -61,7 +61,12 @@ internal class DeepCopyIrTreeWithSymbolsForInliner(
|
||||
}
|
||||
|
||||
override fun visitField(declaration: IrField) {
|
||||
(declaration.descriptor as? WrappedFieldDescriptor)?.bind(declaration)
|
||||
(declaration.descriptor as WrappedFieldDescriptor).bind(declaration)
|
||||
declaration.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
override fun visitProperty(declaration: IrProperty) {
|
||||
(declaration.descriptor as WrappedPropertyDescriptor).bind(declaration)
|
||||
declaration.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
@@ -122,6 +127,9 @@ internal class DeepCopyIrTreeWithSymbolsForInliner(
|
||||
override fun remapDeclaredField(descriptor: PropertyDescriptor) =
|
||||
WrappedFieldDescriptor(descriptor.annotations, descriptor.source)
|
||||
|
||||
override fun remapDeclaredProperty(descriptor: PropertyDescriptor) =
|
||||
WrappedPropertyDescriptor(descriptor.annotations, descriptor.source)
|
||||
|
||||
override fun remapDeclaredSimpleFunction(descriptor: FunctionDescriptor) =
|
||||
WrappedSimpleFunctionDescriptor(descriptor.annotations, descriptor.source)
|
||||
|
||||
|
||||
@@ -84,10 +84,7 @@ open class DeepCopySymbolRemapper(
|
||||
|
||||
override fun visitField(declaration: IrField) {
|
||||
remapSymbol(fields, declaration) {
|
||||
if (declaration.correspondingProperty == null)
|
||||
IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredField(it.descriptor))
|
||||
else
|
||||
IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredProperty(it.descriptor))
|
||||
IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredField(it.descriptor))
|
||||
}
|
||||
declaration.acceptChildrenVoid(this)
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class Delegate {
|
||||
var inner = "OK"
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): String = inner
|
||||
}
|
||||
|
||||
inline fun <T> foo(b: () -> T): T {
|
||||
return b()
|
||||
}
|
||||
|
||||
fun del() = Delegate()
|
||||
|
||||
// MODULE: lib2(lib)
|
||||
// FILE: lib2.kt
|
||||
|
||||
fun qux() = foo {
|
||||
val f = object {
|
||||
val a by del()
|
||||
}
|
||||
|
||||
f.a
|
||||
}
|
||||
|
||||
// MODULE: main(lib2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
return qux()
|
||||
}
|
||||
+5
@@ -9305,6 +9305,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideInlinedObjectMultiModule.kt")
|
||||
public void testInsideInlinedObjectMultiModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4138.kt")
|
||||
public void testKt4138() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");
|
||||
|
||||
+5
@@ -9305,6 +9305,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideInlinedObjectMultiModule.kt")
|
||||
public void testInsideInlinedObjectMultiModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4138.kt")
|
||||
public void testKt4138() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");
|
||||
|
||||
+5
@@ -9305,6 +9305,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideInlinedObjectMultiModule.kt")
|
||||
public void testInsideInlinedObjectMultiModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4138.kt")
|
||||
public void testKt4138() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");
|
||||
|
||||
Generated
+5
@@ -7095,6 +7095,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideInlinedObjectMultiModule.kt")
|
||||
public void testInsideInlinedObjectMultiModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4138.kt")
|
||||
public void testKt4138() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");
|
||||
|
||||
+5
@@ -8180,6 +8180,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insideInlinedObjectMultiModule.kt")
|
||||
public void testInsideInlinedObjectMultiModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/insideInlinedObjectMultiModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4138.kt")
|
||||
public void testKt4138() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegatedProperty/kt4138.kt");
|
||||
|
||||
Reference in New Issue
Block a user