correct handling of delegate properties #KT-2786 fixed
This commit is contained in:
@@ -1510,9 +1510,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor;
|
||||
boolean overridesTrait = isOverrideForTrait(propertyDescriptor);
|
||||
boolean isFakeOverride = propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE;
|
||||
boolean isDelegate = propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION;
|
||||
PropertyDescriptor initialDescriptor = propertyDescriptor;
|
||||
propertyDescriptor = initialDescriptor.getOriginal();
|
||||
boolean isInsideClass = !isFakeOverride &&
|
||||
!isDelegate &&
|
||||
(((containingDeclaration == null && !context.hasThisDescriptor() ||
|
||||
context.hasThisDescriptor() && containingDeclaration == context.getThisDescriptor()) ||
|
||||
(context.getParentContext() instanceof NamespaceContext) &&
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
trait FooTrait {
|
||||
val propertyTest: String
|
||||
}
|
||||
|
||||
class FooDelegate: FooTrait {
|
||||
override val propertyTest: String = "OK"
|
||||
}
|
||||
|
||||
class DelegateTest(): FooTrait by FooDelegate() {
|
||||
fun test() = propertyTest
|
||||
}
|
||||
|
||||
fun box() = DelegateTest().test()
|
||||
@@ -280,6 +280,11 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
blackBoxFile("regressions/kt2509.kt");
|
||||
}
|
||||
|
||||
public void testKt2786() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("regressions/kt2786.kt");
|
||||
}
|
||||
|
||||
public void testKt1528() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt1528_1.kt", "regressions/kt1528_3.kt");
|
||||
|
||||
Reference in New Issue
Block a user