Add some tests for inference and DFA of try/catch/finally

This commit is contained in:
Dmitriy Novozhilov
2019-02-17 12:15:27 +03:00
parent 8d3271cc68
commit 4e64b07727
16 changed files with 865 additions and 0 deletions
@@ -0,0 +1,110 @@
// !WITH_NEW_INFERENCE
class ExcA : Exception()
class ExcB : Exception()
fun test2() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
catch (e: ExcB) {
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>10<!>
}
s<!UNSAFE_CALL!>.<!>length
}
fun test3() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
catch (e: ExcB) {
return
}
s<!UNSAFE_CALL!>.<!>length
}
fun test4() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
finally {
<!UNUSED_EXPRESSION!>""<!>
}
s<!UNSAFE_CALL!>.<!>length
}
fun test5() {
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>s<!>: String? =<!> try {
""
}
catch (e: ExcA) {
null
}
finally {
return
}
<!UNREACHABLE_CODE!>s<!UNSAFE_CALL!>.<!>length<!>
}
fun test6() {
val s: String? = try {
""
}
catch (e: ExcA) {
return
}
catch (e: ExcB) {
return
}
s<!UNSAFE_CALL!>.<!>length
}
fun test7() {
val s: String? = try {
""
}
catch (e: ExcA) {
""
}
catch (e: ExcB) {
""
}
s<!UNSAFE_CALL!>.<!>length
}
fun test8() {
val s = try {
""
} catch (e: ExcA) {
null
}
s<!UNSAFE_CALL!>.<!>length
}
fun test9() {
val s = try {
""
} catch (e: ExcA) {
""
}
s.length
}
fun test10() {
val x = try {
""
} finally {
<!UNUSED_EXPRESSION!>42<!>
}
x.length
}
@@ -0,0 +1,49 @@
package
public fun test10(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(): kotlin.Unit
public fun test6(): kotlin.Unit
public fun test7(): kotlin.Unit
public fun test8(): kotlin.Unit
public fun test9(): kotlin.Unit
public final class ExcA : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcA()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ExcB : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcB()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,100 @@
// !WTIH_NEW_INFERENCE
class ExcA : Exception()
class ExcB : Exception()
fun test0(x: Int?) {
val y = try {
x
} finally {
}
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
y<!UNSAFE_CALL!>.<!>inc()
}
if (y != null) {
x<!UNSAFE_CALL!>.<!>inc()
<!DEBUG_INFO_SMARTCAST!>y<!>.inc()
}
}
fun test1(x: Int?) {
val y = try {
x
}
catch (e: Exception) {
42
}
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
y<!UNSAFE_CALL!>.<!>inc()
}
if (y != null) {
x<!UNSAFE_CALL!>.<!>inc()
<!DEBUG_INFO_SMARTCAST!>y<!>.inc()
}
}
fun test2(x: Int?) {
val y = try {
x
}
catch (e: Exception) {
x
}
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
y<!UNSAFE_CALL!>.<!>inc()
}
if (y != null) {
x<!UNSAFE_CALL!>.<!>inc()
<!DEBUG_INFO_SMARTCAST!>y<!>.inc()
}
}
fun test3(x: Int?) {
val y = try {
x
} catch (e: Exception) {
return
}
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
y<!UNSAFE_CALL!>.<!>inc()
}
if (y != null) {
x<!UNSAFE_CALL!>.<!>inc()
<!DEBUG_INFO_SMARTCAST!>y<!>.inc()
}
}
fun test5(x: Int?) {
val y = try {
x
}
catch (e: ExcA) {
return
}
catch (e: ExcB) {
x
}
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.inc()
y<!UNSAFE_CALL!>.<!>inc()
}
if (y != null) {
x<!UNSAFE_CALL!>.<!>inc()
<!DEBUG_INFO_SMARTCAST!>y<!>.inc()
}
}
@@ -0,0 +1,45 @@
package
public fun test0(/*0*/ x: kotlin.Int?): kotlin.Unit
public fun test1(/*0*/ x: kotlin.Int?): kotlin.Unit
public fun test2(/*0*/ x: kotlin.Int?): kotlin.Unit
public fun test3(/*0*/ x: kotlin.Int?): kotlin.Unit
public fun test5(/*0*/ x: kotlin.Int?): kotlin.Unit
public final class ExcA : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcA()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ExcB : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcB()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,53 @@
// !WTIH_NEW_INFERENCE
class MyException : Exception() {
val myField = "field"
fun myFun() {}
}
fun test1() {
val <!UNUSED_VARIABLE!>e<!> = "something"
try {}
catch (e: Exception) {
e.message
e.<!UNRESOLVED_REFERENCE!>length<!>
}
}
fun test2() {
try {}
catch (e: Exception) {
val <!NAME_SHADOWING!>e<!> = "something"
e.<!UNRESOLVED_REFERENCE!>message<!>
e.length
}
}
fun test3() {
try {}
catch (e: MyException) {
e.myField
}
}
fun test4() {
try {}
catch (e: Exception) {
val <!REDECLARATION, UNUSED_VARIABLE!>a<!> = 42
val <!NAME_SHADOWING, REDECLARATION, UNUSED_VARIABLE!>a<!> = "foo"
}
}
fun test5() {
try {}
catch (e: Exception) {
val <!UNUSED_VARIABLE!>a<!>: Int = 42
try {}
catch (e: MyException) {
e.myFun()
val <!NAME_SHADOWING!>a<!>: String = ""
a.length
}
}
}
@@ -0,0 +1,28 @@
package
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(): kotlin.Unit
public final class MyException : kotlin.Exception /* = java.lang.Exception */ {
public constructor MyException()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final val myField: kotlin.String = "field"
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public final fun myFun(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,87 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
// Related issue: KT-28370
class ExcA : Exception()
class ExcB : Exception()
fun test1(s: String?) {
var t2: Boolean? = true
if (t2 != null) {
try {
t2 = null
}
catch (e: Exception) {
requireNotNull(s)
}
t2<!UNSAFE_CALL!>.<!>not()
s<!UNSAFE_CALL!>.<!>length
}
}
fun test2(s: String?) {
var t2: Boolean? = true
if (t2 != null) {
try {
t2 = null
}
finally {
requireNotNull(s)
t2 = true
}
<!DEBUG_INFO_SMARTCAST!>t2<!>.not()
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
}
fun test3() {
var s: String? = null
s = ""
try {
}
catch (e: Exception) {
s = null
return
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
fun test4() {
var s: String? = null
s = ""
try {
}
catch (e: ExcA) {
s = null
return
}
catch (e: ExcB) {
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
fun test5(s: String?) {
try {
requireNotNull(s)
}
catch (e: ExcA) {
return
}
catch (e: ExcB) {
}
s<!UNSAFE_CALL!>.<!>length
}
fun test6(s: String?) {
try {
requireNotNull(s)
}
catch (e: Exception) {
return
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
@@ -0,0 +1,46 @@
package
public fun test1(/*0*/ s: kotlin.String?): kotlin.Unit
public fun test2(/*0*/ s: kotlin.String?): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(/*0*/ s: kotlin.String?): kotlin.Unit
public fun test6(/*0*/ s: kotlin.String?): kotlin.Unit
public final class ExcA : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcA()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ExcB : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcB()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
// Related issue: KT-28370
fun test1(s1: String?) {
var s: String? = null
s = ""
try {
s = ""
requireNotNull(s1)
}
catch (e: Exception) {
return
}
finally {
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
@@ -0,0 +1,3 @@
package
public fun test1(/*0*/ s1: kotlin.String?): kotlin.Unit
@@ -0,0 +1,105 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
// Related issue: KT-28370
class ExcA : Exception()
class ExcB : Exception()
fun test1() {
var x: String? = null
x = ""
try {
x = null
} catch (e: Exception) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length // smartcast shouldn't be allowed (OOME could happen after `x = null`)
throw e
}
finally {
// smartcast shouldn't be allowed, `x = null` could've happened
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
// smartcast shouldn't be allowed, `x = null` could've happened
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
// With old DFA of try/catch info about unsound smartcasts after try
// removes only if there is at least one catch branch that not returns Nothing
fun test2() {
var x: String? = null
x = ""
try {
x = null
} catch (e: Exception) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
}
finally {
x<!UNSAFE_CALL!>.<!>length
}
x<!UNSAFE_CALL!>.<!>length
}
fun test3() {
var t2: Boolean? = true
if (t2 != null) { // or `t2 is Boolean`
try {
throw Exception()
} catch (e: Exception) {
t2 = null
}
<!DEBUG_INFO_SMARTCAST!>t2<!>.not() // wrong smartcast, NPE
}
}
fun test4() {
var t2: Boolean? = true
if (t2 != null) { // or `t2 is Boolean`
try {
t2 = null
} finally { }
<!DEBUG_INFO_SMARTCAST!>t2<!>.not() // wrong smartcast, NPE
}
}
fun test5() {
var s1: String? = null
var s2: String? = null
s1 = ""
s2 = ""
try {
TODO()
}
catch (e: ExcA) {
s1 = ""
}
catch (e: ExcB) {
s2 = null
return
}
finally {
<!DEBUG_INFO_SMARTCAST!>s1<!>.length
<!DEBUG_INFO_SMARTCAST!>s2<!>.length
}
<!DEBUG_INFO_SMARTCAST!>s1<!>.length
<!DEBUG_INFO_SMARTCAST!>s2<!>.length
}
fun test6(s1: String?, s2: String?) {
var s: String? = null
s = ""
try {
s = null
requireNotNull(s1)
}
catch (e: Exception) {
return
}
finally {
<!DEBUG_INFO_SMARTCAST!>s<!>.length
requireNotNull(s2)
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
s1<!UNSAFE_CALL!>.<!>length
<!DEBUG_INFO_SMARTCAST!>s2<!>.length
}
@@ -0,0 +1,46 @@
package
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(): kotlin.Unit
public fun test6(/*0*/ s1: kotlin.String?, /*1*/ s2: kotlin.String?): kotlin.Unit
public final class ExcA : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcA()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ExcB : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcB()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,34 @@
// !WITH_NEW_INFERENCE
class ExcA : Exception()
class ExcB(val map: Map<Int, Int>) : Exception()
fun test0(): List<Int> = run {
try {
emptyList()
} finally {
<!UNUSED_EXPRESSION!>""<!>
fun foo() {}
}
}
fun test1(): Map<Int, Int> = <!NI;TYPE_MISMATCH!>run {
<!NI;TYPE_MISMATCH!>try {
emptyMap()
} catch (e: ExcA) {
emptyMap()
} catch (e: ExcB) {
e.map
} finally {
<!UNUSED_EXPRESSION!>""<!>
}<!>
}<!>
fun test2(): Map<Int, Int> = <!NI;TYPE_MISMATCH!>run {
<!NI;TYPE_MISMATCH!>try {
emptyMap()
} catch (e: ExcA) {
<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>mapOf("" to "")<!>
}<!>
}<!>
@@ -0,0 +1,44 @@
package
public fun test0(): kotlin.collections.List<kotlin.Int>
public fun test1(): kotlin.collections.Map<kotlin.Int, kotlin.Int>
public fun test2(): kotlin.collections.Map<kotlin.Int, kotlin.Int>
public final class ExcA : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcA()
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class ExcB : kotlin.Exception /* = java.lang.Exception */ {
public constructor ExcB(/*0*/ map: kotlin.collections.Map<kotlin.Int, kotlin.Int>)
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public final val map: kotlin.collections.Map<kotlin.Int, kotlin.Int>
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -3234,6 +3234,54 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/tryCatch")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TryCatch extends AbstractDiagnosticsTestWithStdLib {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInTryCatch() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/tryCatch"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("assignTry.kt")
public void testAssignTry() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.kt");
}
@TestMetadata("boundedSmartcasts.kt")
public void testBoundedSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/boundedSmartcasts.kt");
}
@TestMetadata("catchRedeclaration.kt")
public void testCatchRedeclaration() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/catchRedeclaration.kt");
}
@TestMetadata("correctSmartcasts.kt")
public void testCorrectSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/correctSmartcasts.kt");
}
@TestMetadata("falseNegativeSmartcasts.kt")
public void testFalseNegativeSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/falseNegativeSmartcasts.kt");
}
@TestMetadata("falsePositiveSmartcasts.kt")
public void testFalsePositiveSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/falsePositiveSmartcasts.kt");
}
@TestMetadata("tryExpression.kt")
public void testTryExpression() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/tryExpression.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/typealias")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -3234,6 +3234,54 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/tryCatch")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TryCatch extends AbstractDiagnosticsTestWithStdLibUsingJavac {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInTryCatch() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/tryCatch"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("assignTry.kt")
public void testAssignTry() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.kt");
}
@TestMetadata("boundedSmartcasts.kt")
public void testBoundedSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/boundedSmartcasts.kt");
}
@TestMetadata("catchRedeclaration.kt")
public void testCatchRedeclaration() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/catchRedeclaration.kt");
}
@TestMetadata("correctSmartcasts.kt")
public void testCorrectSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/correctSmartcasts.kt");
}
@TestMetadata("falseNegativeSmartcasts.kt")
public void testFalseNegativeSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/falseNegativeSmartcasts.kt");
}
@TestMetadata("falsePositiveSmartcasts.kt")
public void testFalsePositiveSmartcasts() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/falsePositiveSmartcasts.kt");
}
@TestMetadata("tryExpression.kt")
public void testTryExpression() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/tryCatch/tryExpression.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/typealias")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)