JVM_IR: handle property references at class level
This commit is contained in:
+3
-1
@@ -226,7 +226,9 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
||||
//
|
||||
private fun createSpecializedKProperty(expression: IrCallableReference): IrExpression {
|
||||
val referenceClass = createKPropertySubclass(expression)
|
||||
return context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset)
|
||||
return context.createIrBuilder(
|
||||
currentScope?.scope?.scopeOwnerSymbol ?: irClass.symbol, expression.startOffset, expression.endOffset
|
||||
)
|
||||
.irBlock {
|
||||
+referenceClass
|
||||
+irCall(referenceClass.constructors.single()).apply {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
class Q {
|
||||
val s = "OK"
|
||||
}
|
||||
|
||||
enum class PropEnum(val prop: KProperty1<Q, String>) {
|
||||
ELEM(Q::s)
|
||||
}
|
||||
|
||||
fun box() = PropEnum.ELEM.prop.get(Q())
|
||||
+5
@@ -2456,6 +2456,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
+5
@@ -2456,6 +2456,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
+5
@@ -2436,6 +2436,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
+5
@@ -2436,6 +2436,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
Generated
+5
@@ -1911,6 +1911,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
+5
@@ -1911,6 +1911,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inEnum.kt")
|
||||
public void testInEnum() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/inEnum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokePropertyReference.kt")
|
||||
public void testInvokePropertyReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/property/invokePropertyReference.kt");
|
||||
|
||||
Reference in New Issue
Block a user