Fix .put() for some stack values
#KT-3087 Fixed
This commit is contained in:
@@ -488,20 +488,8 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
if (type == Type.VOID_TYPE) {
|
||||
return;
|
||||
}
|
||||
if (type.equals(JET_TUPLE0_TYPE)) {
|
||||
putTuple0Instance(v);
|
||||
return;
|
||||
}
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(getType(Boolean.class))) {
|
||||
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type " + type);
|
||||
}
|
||||
putAsBoolean(v);
|
||||
if (type != Type.BOOLEAN_TYPE) {
|
||||
box(Type.BOOLEAN_TYPE, type, v);
|
||||
}
|
||||
coerceTo(type, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -580,17 +568,8 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
if (type == Type.VOID_TYPE) {
|
||||
myOperand.put(type, v); // the operand will remove itself from the stack if needed
|
||||
return;
|
||||
}
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(getType(Boolean.class))) {
|
||||
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type");
|
||||
}
|
||||
putAsBoolean(v);
|
||||
if (type != Type.BOOLEAN_TYPE) {
|
||||
box(Type.BOOLEAN_TYPE, type, v);
|
||||
}
|
||||
coerceTo(type, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
fun putNumberCompareAsUnit() {
|
||||
if (1 == 1) {
|
||||
}
|
||||
else if (1 == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
fun putNumberCompareAsVoid() {
|
||||
if (1 == 1) {
|
||||
1 == 1
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
fun putInvertAsUnit(b: Boolean) {
|
||||
if (1 == 1) {
|
||||
} else if (!b) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
putNumberCompareAsUnit()
|
||||
putNumberCompareAsVoid()
|
||||
putInvertAsUnit(true)
|
||||
return "OK"
|
||||
}
|
||||
@@ -474,4 +474,9 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("controlStructures/finallyOnEmptyReturn.kt");
|
||||
}
|
||||
|
||||
public void testKt3087() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("regressions/kt3087.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user