Generate property initializer within property scope
This commit is contained in:
+4
-4
@@ -97,8 +97,8 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
ktProperty.startOffset, ktProperty.endOffset,
|
ktProperty.startOffset, ktProperty.endOffset,
|
||||||
IrDeclarationOrigin.DEFINED, false,
|
IrDeclarationOrigin.DEFINED, false,
|
||||||
propertyDescriptor
|
propertyDescriptor
|
||||||
).apply {
|
).buildWithScope { irProperty ->
|
||||||
backingField =
|
irProperty.backingField =
|
||||||
if (propertyDescriptor.hasBackingField())
|
if (propertyDescriptor.hasBackingField())
|
||||||
generatePropertyBackingField(ktProperty, propertyDescriptor) { irField ->
|
generatePropertyBackingField(ktProperty, propertyDescriptor) { irField ->
|
||||||
ktProperty.initializer?.let { ktInitializer ->
|
ktProperty.initializer?.let { ktInitializer ->
|
||||||
@@ -108,9 +108,9 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|
||||||
getter = generateGetterIfRequired(ktProperty, propertyDescriptor)
|
irProperty.getter = generateGetterIfRequired(ktProperty, propertyDescriptor)
|
||||||
|
|
||||||
setter = generateSetterIfRequired(ktProperty, propertyDescriptor)
|
irProperty.setter = generateSetterIfRequired(ktProperty, propertyDescriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PropertyDescriptor.hasBackingField(): Boolean =
|
private fun PropertyDescriptor.hasBackingField(): Boolean =
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
val test = try { } catch (e : Throwable) { }
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
FILE /catchParameterInTopLevelProperty.kt
|
||||||
|
PROPERTY public val test: kotlin.Unit
|
||||||
|
FIELD PROPERTY_BACKING_FIELD public val test: kotlin.Unit
|
||||||
|
EXPRESSION_BODY
|
||||||
|
TRY type=kotlin.Unit
|
||||||
|
try: BLOCK type=kotlin.Unit origin=null
|
||||||
|
CATCH parameter=e: Throwable
|
||||||
|
VAR CATCH_PARAMETER val e: kotlin.Throwable
|
||||||
|
BLOCK type=kotlin.Unit origin=null
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR public fun <get-test>(): kotlin.Unit
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='<get-test>(): Unit'
|
||||||
|
GET_FIELD 'test: Unit' type=kotlin.Unit origin=null
|
||||||
@@ -227,6 +227,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("catchParameterInTopLevelProperty.kt")
|
||||||
|
public void testCatchParameterInTopLevelProperty() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/catchParameterInTopLevelProperty.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classLevelProperties.kt")
|
@TestMetadata("classLevelProperties.kt")
|
||||||
public void testClassLevelProperties() throws Exception {
|
public void testClassLevelProperties() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/classLevelProperties.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/classLevelProperties.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user