[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// SKIP_TXT
|
||||
|
||||
class ExcA : Exception()
|
||||
|
||||
class ExcB : Exception()
|
||||
|
||||
fun test2() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
null
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
10
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
null
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
return
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
null
|
||||
}
|
||||
finally {
|
||||
""
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
null
|
||||
}
|
||||
finally {
|
||||
return
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
return
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test7() {
|
||||
val s: String? = try {
|
||||
""
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
""
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
""
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test8() {
|
||||
val s = try {
|
||||
""
|
||||
} catch (e: ExcA) {
|
||||
null
|
||||
}
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
val s = try {
|
||||
""
|
||||
} catch (e: ExcA) {
|
||||
""
|
||||
}
|
||||
s.length
|
||||
}
|
||||
|
||||
fun test10() {
|
||||
val x = try {
|
||||
""
|
||||
} finally {
|
||||
42
|
||||
}
|
||||
x.length
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
// !WTIH_NEW_INFERENCE
|
||||
// SKIP_TXT
|
||||
|
||||
class ExcA : Exception()
|
||||
class ExcB : Exception()
|
||||
|
||||
fun test0(x: Int?) {
|
||||
val y = try {
|
||||
x
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
x.inc()
|
||||
y.<!AMBIGUITY!>inc<!>()
|
||||
}
|
||||
|
||||
if (y != null) {
|
||||
x.<!AMBIGUITY!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test1(x: Int?) {
|
||||
val y = try {
|
||||
x
|
||||
}
|
||||
catch (e: Exception) {
|
||||
42
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
x.inc()
|
||||
y.<!AMBIGUITY!>inc<!>()
|
||||
}
|
||||
|
||||
if (y != null) {
|
||||
x.<!AMBIGUITY!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Int?) {
|
||||
val y = try {
|
||||
x
|
||||
}
|
||||
catch (e: Exception) {
|
||||
x
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
x.inc()
|
||||
y.<!AMBIGUITY!>inc<!>()
|
||||
}
|
||||
|
||||
if (y != null) {
|
||||
x.<!AMBIGUITY!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x: Int?) {
|
||||
val y = try {
|
||||
x
|
||||
} catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
x.inc()
|
||||
y.<!AMBIGUITY!>inc<!>()
|
||||
}
|
||||
|
||||
if (y != null) {
|
||||
x.<!AMBIGUITY!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Int?) {
|
||||
val y = try {
|
||||
x
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
x
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
x.inc()
|
||||
y.<!AMBIGUITY!>inc<!>()
|
||||
}
|
||||
|
||||
if (y != null) {
|
||||
x.<!AMBIGUITY!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !WTIH_NEW_INFERENCE
|
||||
// SKIP_TXT
|
||||
|
||||
class MyException : Exception() {
|
||||
val myField = "field"
|
||||
|
||||
fun myFun() {}
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
val e = "something"
|
||||
try {}
|
||||
catch (e: Exception) {
|
||||
e.message
|
||||
e.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
try {}
|
||||
catch (e: Exception) {
|
||||
val e = "something"
|
||||
e.<!UNRESOLVED_REFERENCE!>message<!>
|
||||
e.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
try {}
|
||||
catch (e: MyException) {
|
||||
e.myField
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
try {}
|
||||
catch (e: Exception) {
|
||||
val a = 42
|
||||
val a = "foo"
|
||||
}
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
try {}
|
||||
catch (e: Exception) {
|
||||
val a: Int = 42
|
||||
try {}
|
||||
catch (e: MyException) {
|
||||
e.myFun()
|
||||
val a: String = ""
|
||||
a.length
|
||||
}
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// SKIP_TXT
|
||||
// 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.<!UNRESOLVED_REFERENCE!>not<!>()
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(s: String?) {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) {
|
||||
try {
|
||||
t2 = null
|
||||
}
|
||||
finally {
|
||||
requireNotNull(s)
|
||||
t2 = true
|
||||
}
|
||||
t2.<!UNRESOLVED_REFERENCE!>not<!>()
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
|
||||
}
|
||||
catch (e: Exception) {
|
||||
s = null
|
||||
return
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
s = null
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test5(s: String?) {
|
||||
try {
|
||||
requireNotNull(s)
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
|
||||
}
|
||||
s.length
|
||||
}
|
||||
|
||||
fun test6(s: String?) {
|
||||
try {
|
||||
requireNotNull(s)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
s.length
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +NewDataFlowForTryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// SKIP_TXT
|
||||
// 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.<!UNRESOLVED_REFERENCE!>not<!>()
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(s: String?) {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) {
|
||||
try {
|
||||
t2 = null
|
||||
}
|
||||
finally {
|
||||
requireNotNull(s)
|
||||
t2 = true
|
||||
}
|
||||
t2.<!UNRESOLVED_REFERENCE!>not<!>()
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
|
||||
}
|
||||
catch (e: Exception) {
|
||||
s = null
|
||||
return
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
s = null
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test5(s: String?) {
|
||||
try {
|
||||
requireNotNull(s)
|
||||
}
|
||||
catch (e: ExcA) {
|
||||
return
|
||||
}
|
||||
catch (e: ExcB) {
|
||||
|
||||
}
|
||||
s.length
|
||||
}
|
||||
|
||||
fun test6(s: String?) {
|
||||
try {
|
||||
requireNotNull(s)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
s.length
|
||||
}
|
||||
+19
@@ -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 {
|
||||
s.length
|
||||
}
|
||||
s.length
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +NewDataFlowForTryExpressions
|
||||
// !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 {
|
||||
s.length
|
||||
}
|
||||
s.length
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// SKIP_TXT
|
||||
// Related issue: KT-28370
|
||||
|
||||
class ExcA : Exception()
|
||||
class ExcB : Exception()
|
||||
|
||||
fun test1() {
|
||||
var x: String? = null
|
||||
x = ""
|
||||
|
||||
try {
|
||||
x = null
|
||||
} catch (e: Exception) {
|
||||
x.<!UNRESOLVED_REFERENCE!>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
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
// smartcast shouldn't be allowed, `x = null` could've happened
|
||||
x.<!UNRESOLVED_REFERENCE!>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) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
finally {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) { // or `t2 is Boolean`
|
||||
try {
|
||||
throw Exception()
|
||||
} catch (e: Exception) {
|
||||
t2 = null
|
||||
}
|
||||
t2.<!UNRESOLVED_REFERENCE!>not<!>() // wrong smartcast, NPE
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) { // or `t2 is Boolean`
|
||||
try {
|
||||
t2 = null
|
||||
} finally { }
|
||||
t2.<!UNRESOLVED_REFERENCE!>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 {
|
||||
s1.length
|
||||
s2.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
s1.length
|
||||
s2.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test6(s1: String?, s2: String?) {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
s = null
|
||||
requireNotNull(s1)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
finally {
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
requireNotNull(s2)
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
s1.length
|
||||
s2.length
|
||||
}
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !LANGUAGE: +NewDataFlowForTryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// SKIP_TXT
|
||||
// Related issue: KT-28370
|
||||
|
||||
class ExcA : Exception()
|
||||
class ExcB : Exception()
|
||||
|
||||
fun test1() {
|
||||
var x: String? = null
|
||||
x = ""
|
||||
|
||||
try {
|
||||
x = null
|
||||
} catch (e: Exception) {
|
||||
x.<!UNRESOLVED_REFERENCE!>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
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
// smartcast shouldn't be allowed, `x = null` could've happened
|
||||
x.<!UNRESOLVED_REFERENCE!>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) {
|
||||
// BAD
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
finally {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) { // or `t2 is Boolean`
|
||||
try {
|
||||
throw Exception()
|
||||
} catch (e: Exception) {
|
||||
t2 = null
|
||||
}
|
||||
t2.<!UNRESOLVED_REFERENCE!>not<!>() // wrong smartcast, NPE
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var t2: Boolean? = true
|
||||
if (t2 != null) { // or `t2 is Boolean`
|
||||
try {
|
||||
t2 = null
|
||||
} finally { }
|
||||
t2.<!UNRESOLVED_REFERENCE!>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 {
|
||||
s1.length
|
||||
s2.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
s1.length
|
||||
s2.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test6(s1: String?, s2: String?) {
|
||||
var s: String? = null
|
||||
s = ""
|
||||
try {
|
||||
s = null
|
||||
requireNotNull(s1)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
finally {
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
requireNotNull(s2)
|
||||
}
|
||||
s.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
s1.length
|
||||
s2.length
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// SKIP_TXT
|
||||
|
||||
class ExcA : Exception()
|
||||
|
||||
class ExcB(val map: Map<Int, Int>) : Exception()
|
||||
|
||||
fun test0(): List<Int> = run {
|
||||
try {
|
||||
emptyList()
|
||||
} finally {
|
||||
""
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
fun test1(): Map<Int, Int> = run {
|
||||
try {
|
||||
emptyMap()
|
||||
} catch (e: ExcA) {
|
||||
emptyMap()
|
||||
} catch (e: ExcB) {
|
||||
e.map
|
||||
} finally {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(): Map<Int, Int> = run {
|
||||
try {
|
||||
emptyMap()
|
||||
} catch (e: ExcA) {
|
||||
mapOf("" to "")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user