Fix 'equals' for NotNullBasicValue

NotNullBasicValues were merged incorrectly sometimes,
which caused problems with INSTANCEOF checks.

 #KT-18779 Fixed
This commit is contained in:
Dmitry Petrov
2017-07-03 14:08:15 +03:00
parent 8121c1d3c4
commit 16505daeea
6 changed files with 44 additions and 1 deletions
@@ -23,7 +23,7 @@ import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
class NotNullBasicValue(type: Type?) : StrictBasicValue(type) {
override fun equals(other: Any?): Boolean = other is NotNullBasicValue
override fun equals(other: Any?): Boolean = other is NotNullBasicValue && other.type == type
// We do not differ not-nullable values, so we should always return the same hashCode
// Actually it doesn't really matter because analyzer is not supposed to store values in hashtables
override fun hashCode() = 0
+19
View File
@@ -0,0 +1,19 @@
sealed class Result {
class Failure(val exception: Exception) : Result()
class Success(val message: String) : Result()
}
fun box(): String {
var result: Result
try {
result = Result.Success("OK")
}
catch (e: Exception) {
result = Result.Failure(Exception())
}
when (result) {
is Result.Failure -> throw result.exception
is Result.Success -> return result.message
}
}
@@ -16229,6 +16229,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("kt18779.kt")
public void testKt18779() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt18779.kt");
doTest(fileName);
}
@TestMetadata("kt1932.kt")
public void testKt1932() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt1932.kt");
@@ -16229,6 +16229,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("kt18779.kt")
public void testKt18779() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt18779.kt");
doTest(fileName);
}
@TestMetadata("kt1932.kt")
public void testKt1932() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt1932.kt");
@@ -16229,6 +16229,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("kt18779.kt")
public void testKt18779() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt18779.kt");
doTest(fileName);
}
@TestMetadata("kt1932.kt")
public void testKt1932() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt1932.kt");
@@ -19895,6 +19895,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("kt18779.kt")
public void testKt18779() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt18779.kt");
doTest(fileName);
}
@TestMetadata("kt1932.kt")
public void testKt1932() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/kt1932.kt");