diff --git a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java index 6b3aef3db84..afba5b74753 100644 --- a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -116,8 +116,7 @@ public class ClosureCodegen { final List params = funDescriptor.getUnsubstitutedValueParameters(); int count = 1; for (ValueParameterDescriptor param : params) { - iv.load(count, JetTypeMapper.TYPE_OBJECT); - iv.checkcast(typeMapper.mapType(param.getOutType())); + StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(typeMapper.mapType(param.getOutType()), iv); count++; } diff --git a/idea/testData/codegen/classes/closureWithParameter.jet b/idea/testData/codegen/classes/closureWithParameter.jet new file mode 100644 index 00000000000..a190ba76e5c --- /dev/null +++ b/idea/testData/codegen/classes/closureWithParameter.jet @@ -0,0 +1,7 @@ +fun box() : String { + return apply( "OK", {(arg: String) => arg } ) +} + +fun apply(arg : String, f : {(p:String) : String}) : String { + return f(arg) +} diff --git a/idea/testData/codegen/classes/closureWithParameterAndBoxing.jet b/idea/testData/codegen/classes/closureWithParameterAndBoxing.jet new file mode 100644 index 00000000000..002d41ede67 --- /dev/null +++ b/idea/testData/codegen/classes/closureWithParameterAndBoxing.jet @@ -0,0 +1,7 @@ +fun box() : String { + return if (apply( 5, {(arg: Int) => arg + 13 } ) == 18) "OK" else "fail" +} + +fun apply(arg : Int, f : {(p:Int) : Int}) : Int { + return f(arg) +} diff --git a/idea/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java b/idea/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java index bebdd171d41..b3b96d74a68 100644 --- a/idea/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java @@ -11,4 +11,12 @@ public class ClosuresGenTest extends CodegenTestCase { public void testSimplestClosureAndBoxing() throws Exception { blackBoxFile("classes/simplestClosureAndBoxing.jet"); } + + public void testClosureWithParameter() throws Exception { + blackBoxFile("classes/closureWithParameter.jet"); + } + + public void testClosureWithParameterAndBoxing() throws Exception { + blackBoxFile("classes/closureWithParameterAndBoxing.jet"); + } }