diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index cdd14209aab..2da7d9a2dd0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -468,8 +468,10 @@ public abstract class StackValue { private StackValue myOperand; private Invert(StackValue operand) { - super(operand.type); + super(Type.BOOLEAN_TYPE); myOperand = operand; + if(myOperand.type != Type.BOOLEAN_TYPE) + throw new UnsupportedOperationException("operand of ! must be boolean"); } @Override diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Not.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Not.java index 25d5377c442..25f259df8c2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Not.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Not.java @@ -38,6 +38,7 @@ public class Not implements IntrinsicMethod { else { stackValue = receiver; } - return StackValue.not(stackValue); + stackValue.put(Type.BOOLEAN_TYPE, v); + return StackValue.not(StackValue.onStack(Type.BOOLEAN_TYPE)); } } diff --git a/compiler/testData/codegen/regressions/kt1538.kt b/compiler/testData/codegen/regressions/kt1538.kt new file mode 100644 index 00000000000..01635ec2279 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt1538.kt @@ -0,0 +1,21 @@ +import java.util.HashMap + +fun parseCatalogs(hashMap: Any?) { + val r = toHasMap(hashMap) + if (!r._1) { + return + } + val nodes = r._2 +} + +fun toHasMap(value: Any?): #(Boolean, HashMap?) { + if(value is HashMap<*, *>) { + return #(true, value as HashMap) + } + return #(false, null as HashMap?) +} + +fun box() : String { + parseCatalogs(null) + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index c400b51caf5..39c5a782e34 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -307,4 +307,9 @@ public class ClassGenTest extends CodegenTestCase { public void testKt1345() throws Exception { blackBoxFile("regressions/kt1345.kt"); } + + public void testKt1538() throws Exception { + blackBoxFile("regressions/kt1538.kt"); + System.out.println(generateToText()); + } }