Closure and boxing parameter

This commit is contained in:
Maxim Shafirov
2011-06-22 21:35:24 +04:00
parent 90038fda02
commit c75ad51d5c
4 changed files with 23 additions and 2 deletions
@@ -116,8 +116,7 @@ public class ClosureCodegen {
final List<ValueParameterDescriptor> 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++;
}
@@ -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)
}
@@ -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)
}
@@ -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");
}
}