JVM_IR KT-39612 process subexpressions recursively in 'name' lowering
This commit is contained in:
Generated
+5
@@ -774,6 +774,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt39612.kt")
|
||||||
|
public void testKt39612() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt39612.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
||||||
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
||||||
|
|||||||
+9
-4
@@ -55,14 +55,19 @@ private class KCallableNamePropertyTransformer(val lower: KCallableNamePropertyL
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitCall(expression: IrCall): IrExpression {
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
val callableReference = expression.dispatchReceiver as? IrCallableReference<*> ?: return expression
|
val callableReference = expression.dispatchReceiver as? IrCallableReference<*>
|
||||||
|
?: return super.visitCall(expression)
|
||||||
|
|
||||||
//TODO rewrite checking
|
|
||||||
val directMember = expression.symbol.owner.let {
|
val directMember = expression.symbol.owner.let {
|
||||||
(it as? IrSimpleFunction)?.correspondingPropertySymbol?.owner ?: it
|
(it as? IrSimpleFunction)?.correspondingPropertySymbol?.owner ?: it
|
||||||
}
|
}
|
||||||
val irClass = directMember.parent as? IrClass ?: return expression
|
|
||||||
if (!irClass.isSubclassOf(lower.context.irBuiltIns.kCallableClass.owner)) return expression
|
val irClass = directMember.parent as? IrClass
|
||||||
|
?: return super.visitCall(expression)
|
||||||
|
if (!irClass.isSubclassOf(lower.context.irBuiltIns.kCallableClass.owner)) {
|
||||||
|
return super.visitCall(expression)
|
||||||
|
}
|
||||||
|
|
||||||
val name = when (directMember) {
|
val name = when (directMember) {
|
||||||
is IrSimpleFunction -> directMember.name
|
is IrSimpleFunction -> directMember.name
|
||||||
is IrProperty -> directMember.name
|
is IrProperty -> directMember.name
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
fun foo() {}
|
||||||
|
|
||||||
|
fun id(s: String) = s
|
||||||
|
|
||||||
|
fun test1() = id(::foo.name)
|
||||||
|
|
||||||
|
fun test2(name: String) = (if (name == ::foo.name) ::foo else ::id).annotations
|
||||||
|
|
||||||
|
// 0 getName
|
||||||
|
// 3 LDC "foo"
|
||||||
+5
@@ -774,6 +774,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt39612.kt")
|
||||||
|
public void testKt39612() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt39612.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
||||||
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
||||||
|
|||||||
+5
@@ -774,6 +774,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt36975.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt39612.kt")
|
||||||
|
public void testKt39612() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/kt39612.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
@TestMetadata("nameIntrinsicWithImplicitThis.kt")
|
||||||
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
public void testNameIntrinsicWithImplicitThis() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
runTest("compiler/testData/codegen/bytecodeText/callableReference/nameIntrinsicWithImplicitThis.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user