Closure and boxing parameter
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user