JVM_IR: handle property references at class level

This commit is contained in:
Georgy Bronnikov
2019-12-11 16:52:04 +03:00
parent 8d303af395
commit 92c2cfa968
8 changed files with 46 additions and 1 deletions
@@ -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())
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");