diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index 38c432917b8..9da8cca4c38 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -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(); diff --git a/compiler/testData/codegen/classes/delegationMethodsWithArgs.kt b/compiler/testData/codegen/classes/delegationMethodsWithArgs.kt new file mode 100644 index 00000000000..d005b035d24 --- /dev/null +++ b/compiler/testData/codegen/classes/delegationMethodsWithArgs.kt @@ -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" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index 854532f7079..ada396c5175 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -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");