Fix codegen & bytecode tests after unifying exceptions in JVM backend

See KT-22275 for details
This commit is contained in:
Mikhail Zarechenskiy
2020-01-20 13:51:11 +03:00
parent 1ed7e33f42
commit 5c5635ce20
34 changed files with 55 additions and 55 deletions
@@ -75,7 +75,7 @@ fun box(): String {
// and returning defaultValue if null was received seems incorrect here
mm.getOrDefault("abc", null)
return "fail 7"
} catch (e: java.lang.IllegalArgumentException) {
} catch (e: java.lang.NullPointerException) {
// Parameter specified as non-null is null
}
+1 -1
View File
@@ -19,7 +19,7 @@ fun box(): String {
try {
test3<Int>()
}
catch(e: TypeCastException) {
catch(e: NullPointerException) {
result3 = "OK"
}
if (result3 != "OK") return "fail: test3"
+2 -2
View File
@@ -35,7 +35,7 @@ fun box(): String {
suspendHere()
}
return "fail 1"
} catch (e: kotlin.KotlinNullPointerException) {
} catch (e: NullPointerException) {
}
try {
@@ -54,7 +54,7 @@ fun box(): String {
result = "fail 5"
}
return "fail 6"
} catch (e: kotlin.KotlinNullPointerException) {
} catch (e: NullPointerException) {
}
try {
@@ -13,7 +13,7 @@ fun box(): String {
try {
val b: String = a[0]
return "Fail: an exception should be thrown"
} catch (e: IllegalStateException) {
} catch (e: NullPointerException) {
val st = (e as java.lang.Throwable).getStackTrace()
if (st.size < 5) {
return "Fail: very small stack trace, should at least have current function and JUnit reflective calls: ${Arrays.toString(st)}"
@@ -15,7 +15,7 @@ private operator fun J.component2() = 2
fun use(x: Any) {}
fun box(): String {
assertFailsWith<IllegalArgumentException> {
assertFailsWith<NullPointerException> {
val (a, b) = J.j()
}
if (!component1Evaluated) return "component1 should be evaluated"
@@ -6,7 +6,7 @@ fun f(x: String) = "Fail 1"
fun box(): String {
return try {
f(J().s())
} catch (e: IllegalStateException) {
} catch (e: NullPointerException) {
if (e.message == "J().s() must not be null")
"OK"
else
@@ -8,11 +8,11 @@ public class Test {
try {
ExtensionKt.foo(null);
}
catch (IllegalArgumentException e) {
catch (NullPointerException e) {
try {
ExtensionKt.getBar(null);
}
catch (IllegalArgumentException f) {
catch (NullPointerException f) {
return "OK";
}
}
@@ -20,18 +20,18 @@ public class Test {
args[i] = null;
try {
f.invoke(args);
} catch (IllegalArgumentException e) {
} catch (NullPointerException e) {
// OK
continue;
} catch (Throwable e) {
throw new AssertionError(
"Incorrect exception (IllegalArgumentException expected): " + e.getClass().getName() + ", parameter index = " + i,
"Incorrect exception (NullPointerException expected): " + e.getClass().getName() + ", parameter index = " + i,
e
);
} finally {
args[i] = o;
}
throw new AssertionError("IllegalArgumentException expected, but nothing was thrown, parameter index = " + i);
throw new AssertionError("NullPointerException expected, but nothing was thrown, parameter index = " + i);
}
}
}
@@ -8,7 +8,7 @@ import kotlin.test.*
operator fun A.inc() = A()
fun box(): String {
assertFailsWith<IllegalArgumentException> {
assertFailsWith<NullPointerException> {
var aNull = A.n()
aNull++
}
@@ -8,7 +8,7 @@ import kotlin.test.*
private operator fun A.inc() = A()
fun box(): String {
assertFailsWith<IllegalArgumentException> {
assertFailsWith<NullPointerException> {
var aNull = A.n()
aNull++
}
@@ -16,7 +16,7 @@ public class F {
inline fun <T, U> expectAssertion(f: () -> (T) -> U): Unit? {
try {
F.passNull(f())
} catch (e: IllegalArgumentException) {
} catch (e: NullPointerException) {
return Unit
}
return null
@@ -10,7 +10,7 @@ class C : I
fun box() = try {
B.f()
"FAIL"
} catch (e: IllegalArgumentException) {
} catch (e: NullPointerException) {
"OK"
}
@@ -8,7 +8,7 @@ import kotlin.test.*
fun String.extension() {}
fun box(): String {
assertFailsWith<IllegalStateException> { J.s().extension() }
assertFailsWith<NullPointerException> { J.s().extension() }
return "OK"
}
@@ -8,7 +8,7 @@ import kotlin.test.*
inline fun String.extension() {}
fun box(): String {
assertFailsWith<IllegalStateException> {
assertFailsWith<NullPointerException> {
J.s().extension()
}
return "OK"
@@ -11,7 +11,7 @@ class C {
}
fun box(): String {
assertFailsWith<IllegalStateException> { C().test() }
assertFailsWith<NullPointerException> { C().test() }
return "OK"
}
@@ -11,7 +11,7 @@ class C {
}
fun box(): String {
assertFailsWith<IllegalStateException> {
assertFailsWith<NullPointerException> {
C().test()
}
return "OK"
@@ -17,11 +17,11 @@ fun box(): String {
try {
Test.callFoo()
return "Fail 1"
} catch (e : IllegalArgumentException) {
} catch (e: NullPointerException) {
if (e.message != "Parameter specified as non-null is null: method A.foo, parameter s") {
return "Fail 2 (message: ${e.message})"
}
} catch (e : Throwable) {
} catch (e: Throwable) {
return "Fail 3 (exception class: ${e::class.simpleName})"
}
return "OK"
@@ -6,7 +6,7 @@ fun f(x: String) = "Fail 1"
fun box(): String {
return try {
f(J.s())
} catch (e: IllegalStateException) {
} catch (e: NullPointerException) {
if (e.message == "J.s() must not be null" || e.message == "s() must not be null")
"OK"
else
@@ -9,7 +9,7 @@ import kotlin.test.*
operator fun A.inc() = A()
fun box(): String {
assertFailsWith<IllegalArgumentException> {
assertFailsWith<NullPointerException> {
var aNull = A.n()
aNull++
}
@@ -8,7 +8,7 @@ import kotlin.test.*
fun String.extension() {}
fun box(): String {
assertFailsWith<IllegalArgumentException> { J.s().extension() }
assertFailsWith<NullPointerException> { J.s().extension() }
return "OK"
}
@@ -12,7 +12,7 @@ fun box(): String {
val a: Any? = null
a as Array<String>
}
catch (e: TypeCastException) {
catch (e: NullPointerException) {
if (e.message != "null cannot be cast to non-null type kotlin.Array<kotlin.String>") {
return "Fail 1: $e"
}
@@ -22,7 +22,7 @@ fun box(): String {
val x: String? = null
x as String
}
catch (e: TypeCastException) {
catch (e: NullPointerException) {
if (e.message != "null cannot be cast to non-null type kotlin.String") {
return "Fail 2: $e"
}
@@ -30,7 +30,7 @@ fun box(): String {
try {
if (jClass.minus0().compareTo(jClass.null0()) != -2) return "fail 3"
return "fail: exception expected";
} catch (e: IllegalStateException) {
} catch (e: NullPointerException) {
}
+1 -1
View File
@@ -31,7 +31,7 @@ fun box(): String {
}
})
}.run()
} catch (e: IllegalArgumentException) {
} catch (e: NullPointerException) {
return "OK"
}
@@ -1,15 +1,15 @@
// KOTLIN_CONFIGURATION_FLAGS: +JVM.DISABLE_PARAM_ASSERTIONS
// FILE: callAssertions.kt
class AssertionChecker(val illegalStateExpected: Boolean) {
class AssertionChecker(val nullPointerExceptionExpected: Boolean) {
operator fun invoke(name: String, f: () -> Any) {
try {
f()
} catch (e: IllegalStateException) {
if (!illegalStateExpected) throw AssertionError("Unexpected IllegalStateException on calling $name")
} catch (e: NullPointerException) {
if (!nullPointerExceptionExpected) throw AssertionError("Unexpected NullPointerException on calling $name")
return
}
if (illegalStateExpected) throw AssertionError("IllegalStateException expected on calling $name")
if (nullPointerExceptionExpected) throw AssertionError("NullPointerException expected on calling $name")
}
}
@@ -15,7 +15,7 @@ fun box(): String {
DelegateFrom().foo()
return "Fail: should have been an exception"
}
catch(e: IllegalStateException) {
catch(e: NullPointerException) {
return "OK"
}
}
@@ -11,10 +11,10 @@ public abstract class C<Type> {
public static void runTest(C a) {
try {
a.doTest(null);
} catch (IllegalArgumentException e) {
} catch (NullPointerException e) {
return;
}
throw new AssertionError("Fail: IllegalArgumentException expected");
throw new AssertionError("Fail: NullPointerException expected");
}
}
@@ -19,13 +19,13 @@ fun box(): String {
foo(baz() ?: RightElvisOperand.foo())
return "Fail: should have been an exception in `foo(baz() ?: RightElvisOperand.foo())`"
}
catch(e: IllegalStateException) {}
catch(e: NullPointerException) {}
try {
bar()
return "Fail: should have been an exception in `bar()`"
}
catch(e: IllegalStateException) {
catch(e: NullPointerException) {
return "OK"
}
}
@@ -19,7 +19,7 @@ fun box(): String {
try {
test(JavaClass().test())
}
catch (e: IllegalStateException) {
catch (e: NullPointerException) {
return "OK"
}
return "fail"
@@ -14,8 +14,8 @@ fun asNullablePrimitive(c: AsNonNullPrimitive?) {}
fun asNullableReference(c: AsNonNullReference?) {}
// JVM_TEMPLATES
// 6 checkParameterIsNotNull
// 0 checkNotNullParameter
// 0 checkParameterIsNotNull
// 6 checkNotNullParameter
// JVM_IR_TEMPLATES
// 4 checkParameterIsNotNull
@@ -8,7 +8,7 @@ fun foo(): Any {
fun bar(a: ArrayList<String>) {
}
// 1 checkExpressionValueIsNotNull
// 0 checkNotNullExpressionValue
// 1 checkParameterIsNotNull
// 0 checkNotNullParameter
// 0 checkExpressionValueIsNotNull
// 1 checkNotNullExpressionValue
// 0 checkParameterIsNotNull
// 1 checkNotNullParameter
@@ -6,5 +6,5 @@ public fun <R : Any> foo(x: MutableCollection<in R>, block: java.util.AbstractLi
x.add(block.get(0))
}
// 1 checkExpressionValueIsNotNull
// 0 checkNotNullExpressionValue
// 0 checkExpressionValueIsNotNull
// 1 checkNotNullExpressionValue
@@ -1,4 +1,4 @@
fun <T : Any> foo(t: T) = t
// 1 checkParameterIsNotNull
// 0 checkNotNullParameter
// 0 checkParameterIsNotNull
// 1 checkNotNullParameter
@@ -32,7 +32,7 @@ internal fun bar(a: A<String, Int>, b: B<String>, c: C) {
}
// @JavaMultipleSubstitutionsKt.class
// 3 checkExpressionValueIsNotNull
// 0 checkNotNullExpressionValue
// 3 checkParameterIsNotNull
// 0 checkNotNullParameter
// 0 checkExpressionValueIsNotNull
// 3 checkNotNullExpressionValue
// 0 checkParameterIsNotNull
// 3 checkNotNullParameter
@@ -21,5 +21,5 @@ fun test() {
// @KKt.class:
// 1 LDC "a"
// 1 checkExpressionValueIsNotNull
// 0 checkNotNullExpressionValue
// 0 checkExpressionValueIsNotNull
// 1 checkNotNullExpressionValue