KT-2657 Fixed incorrect stack values order in delegation methods codegen #KT-2657 Fixed
This commit is contained in:
@@ -705,6 +705,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
field.put(field.type, iv);
|
||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
@@ -719,8 +720,6 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
reg += argType.getSize();
|
||||
}
|
||||
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
field.put(field.type, iv);
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
||||
String internalName =
|
||||
state.getTypeMapper().mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package test
|
||||
|
||||
trait TextField {
|
||||
fun getText(): String
|
||||
}
|
||||
|
||||
trait InputTextField : TextField {
|
||||
fun setText(text: String)
|
||||
}
|
||||
|
||||
trait MooableTextField : InputTextField {
|
||||
fun moo(a: Int, b: Int, c: Int): Int
|
||||
}
|
||||
|
||||
class SimpleTextField : MooableTextField {
|
||||
private var text = ""
|
||||
override fun getText() = text
|
||||
override fun setText(text: String) {
|
||||
this.text = text
|
||||
}
|
||||
override fun moo(a: Int, b: Int, c: Int) = a + b + c
|
||||
}
|
||||
|
||||
class TextFieldWrapper(textField: MooableTextField) : MooableTextField by textField
|
||||
|
||||
fun box() : String {
|
||||
val textField = TextFieldWrapper(SimpleTextField())
|
||||
textField.setText("hello world!")
|
||||
|
||||
if (!textField.getText().equals("hello world!")) return "FAIL #!1"
|
||||
if (textField.moo(1,2,3) != 6) return "FAIL #2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -78,6 +78,11 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
blackBoxFile("classes/delegation4.kt");
|
||||
}
|
||||
|
||||
public void testDelegationMethodsWithArgs() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("classes/delegationMethodsWithArgs.kt");
|
||||
}
|
||||
|
||||
public void testFunDelegation() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("classes/funDelegation.jet");
|
||||
|
||||
Reference in New Issue
Block a user