added test for KT-248
This commit is contained in:
@@ -1613,7 +1613,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
if (!(descriptor instanceof ClassDescriptor)) {
|
if (!(descriptor instanceof ClassDescriptor)) {
|
||||||
throw new UnsupportedOperationException("don't know how to handle non-class types in as/as?");
|
throw new UnsupportedOperationException("don't know how to handle non-class types in as/as?");
|
||||||
}
|
}
|
||||||
Type type = typeMapper.mapType(jetType, OwnerKind.INTERFACE);
|
Type type = typeMapper.boxType(typeMapper.mapType(jetType, OwnerKind.INTERFACE));
|
||||||
generateInstanceOf(StackValue.expression(OBJECT_TYPE, expression.getLeft(), this), jetType, true);
|
generateInstanceOf(StackValue.expression(OBJECT_TYPE, expression.getLeft(), this), jetType, true);
|
||||||
Label isInstance = new Label();
|
Label isInstance = new Label();
|
||||||
v.ifne(isInstance);
|
v.ifne(isInstance);
|
||||||
@@ -1739,7 +1739,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
if (leaveExpressionOnStack) {
|
if (leaveExpressionOnStack) {
|
||||||
v.dup();
|
v.dup();
|
||||||
}
|
}
|
||||||
Type type = typeMapper.mapType(jetType, OwnerKind.INTERFACE);
|
Type type = typeMapper.boxType(typeMapper.mapType(jetType, OwnerKind.INTERFACE));
|
||||||
v.instanceOf(type);
|
v.instanceOf(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun box() : String {
|
||||||
|
val b = true as? Boolean //exception
|
||||||
|
val i = 1 as Int //exception
|
||||||
|
val j = 1 as Int? //ok
|
||||||
|
val s = "s" as String //ok
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -270,4 +270,8 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
|||||||
public void testKt243 () throws Exception {
|
public void testKt243 () throws Exception {
|
||||||
blackBoxFile("regressions/kt243.jet");
|
blackBoxFile("regressions/kt243.jet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt248 () throws Exception {
|
||||||
|
blackBoxFile("regressions/kt248.jet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user