#KT-2811 Fixed VerifyError on smart-cast 'this'

This commit is contained in:
Natalia.Ukhorskaya
2012-10-23 11:42:44 +04:00
parent a3b86f5f8b
commit a79a31cf01
3 changed files with 32 additions and 3 deletions
@@ -1911,9 +1911,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
else if (descriptor instanceof AutoCastReceiver) {
AutoCastReceiver autoCastReceiver = (AutoCastReceiver) descriptor;
Type intermediateType = asmType(autoCastReceiver.getType());
generateFromResolvedCall(autoCastReceiver.getOriginal(), intermediateType);
StackValue.onStack(intermediateType).put(type, v);
Type originalType = asmType(autoCastReceiver.getOriginal().getType());
generateFromResolvedCall(autoCastReceiver.getOriginal(), originalType);
StackValue.onStack(originalType).put(type, v);
}
else {
throw new UnsupportedOperationException("Unsupported receiver type: " + descriptor);
@@ -0,0 +1,25 @@
open class Test1 {
fun test1(): String {
if (this is Test2) {
return this.foo()
}
return "fail"
}
}
class Test2(): Test1() {
fun foo(): String {
return "OK"
}
}
fun Test1.test2(): String {
if (this is Test2) return this.foo() else return "fail"
}
fun box(): String {
if ("OK" == Test2().test1() && "OK" == Test2().test2()) {
return "OK"
}
return "fail"
}
@@ -157,6 +157,10 @@ public class TypeInfoTest extends CodegenTestCase {
// System.out.println(generateToText());
}
public void testKt2811() throws Exception {
blackBoxFile("typeInfo/kt2811.kt");
}
public void testInheritance() throws Exception {
blackBoxFile("typeInfo/inheritance.jet");
// System.out.println(generateToText());