KT-950 wrong call to array-like setter with non-void return type

This commit is contained in:
Alex Tkachman
2012-01-10 15:36:33 +02:00
parent 8a9a591370
commit 5633f71edc
3 changed files with 24 additions and 2 deletions
@@ -531,8 +531,17 @@ public abstract class StackValue {
if (setter == null) {
throw new UnsupportedOperationException("no setter specified");
}
if(setter instanceof CallableMethod)
((CallableMethod)setter).invoke(v);
if(setter instanceof CallableMethod) {
CallableMethod method = (CallableMethod) setter;
method.invoke(v);
Type returnType = method.getSignature().getAsmMethod().getReturnType();
if(returnType != Type.VOID_TYPE) {
if(returnType.getSize() == 2)
v.pop2();
else
v.pop();
}
}
else
((IntrinsicMethod)setter).generate(codegen, v, null, null, null, null);
}
@@ -0,0 +1,9 @@
import java.util.*
fun <K, V> Map<K, V>.set(k : K, v : V) = put(k, v)
fun box() : String {
val map = HashMap<String,String>()
map["239"] = "932"
return if(map["239"] == "932") "OK" else "fail"
}
@@ -286,6 +286,10 @@ public class ArrayGenTest extends CodegenTestCase {
// System.out.println(generateToText());
}
public void testKt950() {
blackBoxFile("regressions/kt950.jet");
}
public void testKt594() throws Exception {
loadFile("regressions/kt594.jet");
// System.out.println(generateToText());