#KT-2811 Fixed VerifyError on smart-cast 'this'
This commit is contained in:
@@ -1911,9 +1911,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
else if (descriptor instanceof AutoCastReceiver) {
|
else if (descriptor instanceof AutoCastReceiver) {
|
||||||
AutoCastReceiver autoCastReceiver = (AutoCastReceiver) descriptor;
|
AutoCastReceiver autoCastReceiver = (AutoCastReceiver) descriptor;
|
||||||
Type intermediateType = asmType(autoCastReceiver.getType());
|
Type originalType = asmType(autoCastReceiver.getOriginal().getType());
|
||||||
generateFromResolvedCall(autoCastReceiver.getOriginal(), intermediateType);
|
generateFromResolvedCall(autoCastReceiver.getOriginal(), originalType);
|
||||||
StackValue.onStack(intermediateType).put(type, v);
|
StackValue.onStack(originalType).put(type, v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new UnsupportedOperationException("Unsupported receiver type: " + descriptor);
|
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());
|
// System.out.println(generateToText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt2811() throws Exception {
|
||||||
|
blackBoxFile("typeInfo/kt2811.kt");
|
||||||
|
}
|
||||||
|
|
||||||
public void testInheritance() throws Exception {
|
public void testInheritance() throws Exception {
|
||||||
blackBoxFile("typeInfo/inheritance.jet");
|
blackBoxFile("typeInfo/inheritance.jet");
|
||||||
// System.out.println(generateToText());
|
// System.out.println(generateToText());
|
||||||
|
|||||||
Reference in New Issue
Block a user