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)
|
IrDeclarationOriginImpl("SYNTHETIC_METHOD_FOR_TYPEALIAS_ANNOTATIONS", isSynthetic = true)
|
||||||
object GENERATED_PROPERTY_REFERENCE : IrDeclarationOriginImpl("GENERATED_PROPERTY_REFERENCE", isSynthetic = true)
|
object GENERATED_PROPERTY_REFERENCE : IrDeclarationOriginImpl("GENERATED_PROPERTY_REFERENCE", isSynthetic = true)
|
||||||
object GENERATED_SAM_IMPLEMENTATION : IrDeclarationOriginImpl("GENERATED_SAM_IMPLEMENTATION", 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 ENUM_MAPPINGS_FOR_WHEN : IrDeclarationOriginImpl("ENUM_MAPPINGS_FOR_WHEN", isSynthetic = true)
|
||||||
object SYNTHETIC_INLINE_CLASS_MEMBER : IrDeclarationOriginImpl("SYNTHETIC_INLINE_CLASS_MEMBER", 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")
|
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 =
|
private fun createConstructor(): IrConstructor =
|
||||||
functionReferenceClass.addConstructor {
|
functionReferenceClass.addConstructor {
|
||||||
setSourceRange(irFunctionReference)
|
setSourceRange(irFunctionReference)
|
||||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||||
returnType = functionReferenceClass.defaultType
|
returnType = functionReferenceClass.defaultType
|
||||||
isPrimary = true
|
isPrimary = true
|
||||||
}.apply {
|
}.apply {
|
||||||
@@ -323,7 +323,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
|||||||
private fun buildOverride(superFunction: IrSimpleFunction, newReturnType: IrType = superFunction.returnType): IrSimpleFunction =
|
private fun buildOverride(superFunction: IrSimpleFunction, newReturnType: IrType = superFunction.returnType): IrSimpleFunction =
|
||||||
functionReferenceClass.addFunction {
|
functionReferenceClass.addFunction {
|
||||||
setSourceRange(irFunctionReference)
|
setSourceRange(irFunctionReference)
|
||||||
origin = functionReferenceClass.origin
|
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||||
name = superFunction.name
|
name = superFunction.name
|
||||||
returnType = newReturnType
|
returnType = newReturnType
|
||||||
visibility = superFunction.visibility
|
visibility = superFunction.visibility
|
||||||
|
|||||||
+2
-2
@@ -79,7 +79,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte
|
|||||||
return irBuilder.irBlock(expression, IrStatementOrigin.LAMBDA) {
|
return irBuilder.irBlock(expression, IrStatementOrigin.LAMBDA) {
|
||||||
val function = buildFun {
|
val function = buildFun {
|
||||||
setSourceRange(expression)
|
setSourceRange(expression)
|
||||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||||
name = Name.identifier("stub_for_inline")
|
name = Name.identifier("stub_for_inline")
|
||||||
visibility = Visibilities.LOCAL
|
visibility = Visibilities.LOCAL
|
||||||
returnType = field.type
|
returnType = field.type
|
||||||
@@ -124,7 +124,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte
|
|||||||
|
|
||||||
val function = buildFun {
|
val function = buildFun {
|
||||||
setSourceRange(expression)
|
setSourceRange(expression)
|
||||||
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
|
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||||
name = Name.identifier("stub_for_inlining")
|
name = Name.identifier("stub_for_inlining")
|
||||||
visibility = Visibilities.LOCAL
|
visibility = Visibilities.LOCAL
|
||||||
returnType = referencedFunction.returnType
|
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.JvmLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder
|
import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.irArrayOf
|
import org.jetbrains.kotlin.backend.jvm.ir.irArrayOf
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
@@ -102,7 +103,8 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
|
|||||||
name = method.name
|
name = method.name
|
||||||
returnType = method.returnType
|
returnType = method.returnType
|
||||||
visibility = method.visibility
|
visibility = method.visibility
|
||||||
origin = this@addOverride.origin
|
modality = Modality.OPEN
|
||||||
|
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||||
}.apply {
|
}.apply {
|
||||||
overriddenSymbols.add(method.symbol)
|
overriddenSymbols.add(method.symbol)
|
||||||
dispatchReceiverParameter = thisReceiver!!.copyTo(this)
|
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);
|
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")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Visibility extends AbstractWriteFlagsTest {
|
public static class Flags extends AbstractWriteFlagsTest {
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInVisibility() throws Exception {
|
public void testAllFilesPresentInFlags() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/visibility"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/flags"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("functionReference.kt")
|
@TestMetadata("functionReference.kt")
|
||||||
public void testFunctionReference() throws Exception {
|
public void testFunctionReference() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReference.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/functionReference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("functionReferenceInInlineFunction.kt")
|
@TestMetadata("functionReferenceInInlineFunction.kt")
|
||||||
public void testFunctionReferenceInInlineFunction() throws Exception {
|
public void testFunctionReferenceInInlineFunction() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/functionReferenceInInlineFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyReference.kt")
|
@TestMetadata("propertyReference.kt")
|
||||||
public void testPropertyReference() throws Exception {
|
public void testPropertyReference() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
||||||
public void testPropertyReferenceInInlineFunction() throws Exception {
|
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);
|
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")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Visibility extends AbstractIrWriteFlagsTest {
|
public static class Flags extends AbstractIrWriteFlagsTest {
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInVisibility() throws Exception {
|
public void testAllFilesPresentInFlags() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/visibility"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/flags"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("functionReference.kt")
|
@TestMetadata("functionReference.kt")
|
||||||
public void testFunctionReference() throws Exception {
|
public void testFunctionReference() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReference.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/functionReference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("functionReferenceInInlineFunction.kt")
|
@TestMetadata("functionReferenceInInlineFunction.kt")
|
||||||
public void testFunctionReferenceInInlineFunction() throws Exception {
|
public void testFunctionReferenceInInlineFunction() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/functionReferenceInInlineFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyReference.kt")
|
@TestMetadata("propertyReference.kt")
|
||||||
public void testPropertyReference() throws Exception {
|
public void testPropertyReference() throws Exception {
|
||||||
runTest("compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt");
|
runTest("compiler/testData/writeFlags/callableReference/flags/propertyReference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
@TestMetadata("propertyReferenceInInlineFunction.kt")
|
||||||
public void testPropertyReferenceInInlineFunction() throws Exception {
|
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