Set non-synthetic origin for generated members of PropertyReference
This commit is contained in:
@@ -39,6 +39,7 @@ interface JvmLoweredDeclarationOrigin : IrDeclarationOrigin {
|
||||
IrDeclarationOriginImpl("SYNTHETIC_METHOD_FOR_TYPEALIAS_ANNOTATIONS", isSynthetic = true)
|
||||
object GENERATED_PROPERTY_REFERENCE : IrDeclarationOriginImpl("GENERATED_PROPERTY_REFERENCE", isSynthetic = true)
|
||||
object GENERATED_SAM_IMPLEMENTATION : IrDeclarationOriginImpl("GENERATED_SAM_IMPLEMENTATION", isSynthetic = true)
|
||||
object GENERATED_MEMBER_IN_CALLABLE_REFERENCE : IrDeclarationOriginImpl("GENERATED_MEMBER_IN_CALLABLE_REFERENCE", isSynthetic = false)
|
||||
object ENUM_MAPPINGS_FOR_WHEN : IrDeclarationOriginImpl("ENUM_MAPPINGS_FOR_WHEN", isSynthetic = true)
|
||||
object SYNTHETIC_INLINE_CLASS_MEMBER : IrDeclarationOriginImpl("SYNTHETIC_INLINE_CLASS_MEMBER", isSynthetic = true)
|
||||
object INLINE_CLASS_GENERATED_IMPL_METHOD : IrDeclarationOriginImpl("INLINE_CLASS_GENERATED_IMPL_METHOD")
|
||||
|
||||
+2
-2
@@ -172,7 +172,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
private fun createConstructor(): IrConstructor =
|
||||
functionReferenceClass.addConstructor {
|
||||
setSourceRange(irFunctionReference)
|
||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
returnType = functionReferenceClass.defaultType
|
||||
isPrimary = true
|
||||
}.apply {
|
||||
@@ -323,7 +323,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
private fun buildOverride(superFunction: IrSimpleFunction, newReturnType: IrType = superFunction.returnType): IrSimpleFunction =
|
||||
functionReferenceClass.addFunction {
|
||||
setSourceRange(irFunctionReference)
|
||||
origin = functionReferenceClass.origin
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
name = superFunction.name
|
||||
returnType = newReturnType
|
||||
visibility = superFunction.visibility
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte
|
||||
return irBuilder.irBlock(expression, IrStatementOrigin.LAMBDA) {
|
||||
val function = buildFun {
|
||||
setSourceRange(expression)
|
||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
name = Name.identifier("stub_for_inline")
|
||||
visibility = Visibilities.LOCAL
|
||||
returnType = field.type
|
||||
@@ -124,7 +124,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte
|
||||
|
||||
val function = buildFun {
|
||||
setSourceRange(expression)
|
||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
name = Name.identifier("stub_for_inlining")
|
||||
visibility = Visibilities.LOCAL
|
||||
returnType = referencedFunction.returnType
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.irArrayOf
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
@@ -102,7 +103,8 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
||||
name = method.name
|
||||
returnType = method.returnType
|
||||
visibility = method.visibility
|
||||
origin = this@addOverride.origin
|
||||
modality = Modality.OPEN
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
}.apply {
|
||||
overriddenSymbols.add(method.symbol)
|
||||
dispatchReceiverParameter = thisReceiver!!.copyTo(this)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
|
||||
val bar = A::foo
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: class
|
||||
// TESTED_OBJECTS: A$bar$1
|
||||
// FLAGS: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getName
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getOwner
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getSignature
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, invoke
|
||||
// FLAGS: ACC_PUBLIC, ACC_FINAL
|
||||
@@ -0,0 +1,25 @@
|
||||
class A {
|
||||
val foo = ""
|
||||
|
||||
val bar = A::foo
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: class
|
||||
// TESTED_OBJECTS: A$bar$1
|
||||
// FLAGS: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getName
|
||||
// FLAGS: ACC_PUBLIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getOwner
|
||||
// FLAGS: ACC_PUBLIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, getSignature
|
||||
// FLAGS: ACC_PUBLIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: A$bar$1, get
|
||||
// FLAGS: ACC_PUBLIC
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class A {
|
||||
fun foo() {}
|
||||
|
||||
val bar = A::foo
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: class
|
||||
// TESTED_OBJECTS: A$bar$1
|
||||
// FLAGS: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class A {
|
||||
val foo = ""
|
||||
|
||||
val bar = A::foo
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: class
|
||||
// TESTED_OBJECTS: A$bar$1
|
||||
// FLAGS: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
|
||||
+8
-8
@@ -41,36 +41,36 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/callableReference/visibility")
|
||||
@TestMetadata("compiler/testData/writeFlags/callableReference/flags")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Visibility extends AbstractWriteFlagsTest {
|
||||
public static class Flags extends AbstractWriteFlagsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInVisibility() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/visibility"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
public void testAllFilesPresentInFlags() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/flags"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("functionReference.kt")
|
||||
public void testFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReference.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/functionReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionReferenceInInlineFunction.kt")
|
||||
public void testFunctionReferenceInInlineFunction() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/functionReferenceInInlineFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyReference.kt")
|
||||
public void testPropertyReference() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
||||
public void testPropertyReferenceInInlineFunction() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReferenceInInlineFunction.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -41,36 +41,36 @@ public class IrWriteFlagsTestGenerated extends AbstractIrWriteFlagsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/callableReference/visibility")
|
||||
@TestMetadata("compiler/testData/writeFlags/callableReference/flags")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Visibility extends AbstractIrWriteFlagsTest {
|
||||
public static class Flags extends AbstractIrWriteFlagsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInVisibility() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/visibility"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
public void testAllFilesPresentInFlags() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/flags"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("functionReference.kt")
|
||||
public void testFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReference.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/functionReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionReferenceInInlineFunction.kt")
|
||||
public void testFunctionReferenceInInlineFunction() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/functionReferenceInInlineFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyReference.kt")
|
||||
public void testPropertyReference() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
||||
public void testPropertyReferenceInInlineFunction() throws Exception {
|
||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt");
|
||||
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReferenceInInlineFunction.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user