FIR DFA: x !is T? => x != null

^KT-22996 tag fixed-in-k2
This commit is contained in:
pyos
2022-11-14 17:18:01 +01:00
committed by teamcity
parent 02fedeb9ed
commit f485413cfd
18 changed files with 118 additions and 53 deletions
@@ -58,7 +58,7 @@ fun f11(a : A?) {
is A -> a.foo()
is Any -> a.foo()
<!USELESS_IS_CHECK!>is Any?<!> -> a.<!UNRESOLVED_REFERENCE!>bar<!>()
else -> a?.foo()
else -> a<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
}
}
@@ -68,8 +68,8 @@ fun f12(a : A?) {
is A -> a.foo()
is Any -> a.foo();
<!USELESS_IS_CHECK!>is Any?<!> -> a.<!UNRESOLVED_REFERENCE!>bar<!>()
is C -> a.bar()
else -> a?.foo()
<!USELESS_IS_CHECK!>is C<!> -> a.bar()
else -> a<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
}
if (<!USELESS_IS_CHECK!>a is Any?<!>) {
@@ -56,5 +56,5 @@ FILE fqName:<root> fileName:/bangbang.kt
then: CALL 'public final fun useString (s: kotlin.String): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL
<T0>: kotlin.String
arg0: TYPE_OP type=kotlin.String? origin=IMPLICIT_CAST typeOperand=kotlin.String?
arg0: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
GET_VAR 'a: X of <root>.test4 declared in <root>.test4' type=X of <root>.test4 origin=null
@@ -24,6 +24,6 @@ fun <X : Any?> test4(a: X) {
a is String? -> CHECK_NOT_NULL<String>(arg0 = a /*as String? */) /*~> Unit */
}
when {
a is String? -> useString(s = CHECK_NOT_NULL<String>(arg0 = a /*as String? */))
a is String? -> useString(s = CHECK_NOT_NULL<String>(arg0 = a /*as String */))
}
}