Synthetic 'field' variable is no more created in extension property accessors #KT-9303 Fixed
This commit is contained in:
@@ -776,11 +776,11 @@ public class BodyResolver {
|
||||
);
|
||||
|
||||
// Synthetic "field" creation
|
||||
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
||||
if (functionDescriptor instanceof PropertyAccessorDescriptor && functionDescriptor.getExtensionReceiverParameter() == null) {
|
||||
PropertyAccessorDescriptor accessorDescriptor = (PropertyAccessorDescriptor) functionDescriptor;
|
||||
JetProperty property = (JetProperty) function.getParent();
|
||||
final SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
||||
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, functionDescriptor.getExtensionReceiverParameter(),
|
||||
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, null,
|
||||
"Accessor inner scope with synthetic field",
|
||||
RedeclarationHandler.DO_NOTHING, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// See KT-9303: synthetic field variable does not exist for extension properties
|
||||
val String.foo: Int
|
||||
get() {
|
||||
// No shadowing here
|
||||
val field = 42
|
||||
return field
|
||||
}
|
||||
|
||||
val String.bar: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>13<!>
|
||||
// Error
|
||||
get() = <!UNRESOLVED_REFERENCE!>field<!>
|
||||
|
||||
class My {
|
||||
val String.x: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>7<!>
|
||||
// Error
|
||||
get() = <!UNRESOLVED_REFERENCE!>field<!>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public val kotlin.String.bar: kotlin.Int = 13
|
||||
public val kotlin.String.foo: kotlin.Int
|
||||
|
||||
public final class My {
|
||||
public constructor My()
|
||||
public final val kotlin.String.x: kotlin.Int = 7
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -1374,6 +1374,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ExtensionProperty.kt")
|
||||
public void testExtensionProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/ExtensionProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("FieldAsParam.kt")
|
||||
public void testFieldAsParam() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/backingField/FieldAsParam.kt");
|
||||
|
||||
Reference in New Issue
Block a user