KT-4340: Jvm backend generates invalid synthetic accessor for private extension property
This commit is contained in:
@@ -1024,9 +1024,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
InstructionAdapter iv = codegen.v;
|
||||
boolean forceField = AsmUtil.isPropertyWithBackingFieldInOuterClass(original) && !isClassObject(bridge.getContainingDeclaration());
|
||||
StackValue property = codegen.intermediateValueForProperty(original, forceField, null, MethodKind.SYNTHETIC_ACCESSOR);
|
||||
if (!forceField) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
|
||||
Type[] argTypes = signature.getAsmMethod().getArgumentTypes();
|
||||
for (int i = 0, reg = 0; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
reg += argType.getSize();
|
||||
}
|
||||
|
||||
property.put(property.type, iv);
|
||||
iv.areturn(signature.getReturnType());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
class A {
|
||||
|
||||
var result: Int = 0;
|
||||
|
||||
private val Int.times3: Int
|
||||
get() = this * 3
|
||||
|
||||
private var Int.times: Int
|
||||
get() = this * 4
|
||||
set(s: Int) {
|
||||
result = this * s
|
||||
}
|
||||
|
||||
fun test(p: Int):Int {
|
||||
return {
|
||||
p.times3
|
||||
}()
|
||||
}
|
||||
|
||||
fun test2(p: Int, s: Int):Int {
|
||||
{
|
||||
p.times = s
|
||||
}()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var result = A().test(3);
|
||||
if (result != 9) return "fail1: $result"
|
||||
|
||||
result = A().test2(2, 4);
|
||||
if (result != 8) return "fail2: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -4689,6 +4689,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/properties/kt4252_2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4340.kt")
|
||||
public void testKt4340() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/properties/kt4340.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4373.kt")
|
||||
public void testKt4373() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/properties/kt4373.kt");
|
||||
|
||||
Reference in New Issue
Block a user