Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/kt2422.fir.kt
T
simon.ogorodnik 34e6649d31 [FIR] Harden check of argument type properly
Before this commit, nullable argument could match not null parameter.
Now we require also correct nullability that breaks some cases
2020-02-03 16:45:18 +03:00

23 lines
537 B
Kotlin
Vendored

package bar
class Test {
val foo: Int? = null
fun foo(o: Test) = foo == null && o.foo == null // ERROR warning: o.test == null is always true
fun bar(a: Test, b: Test) {
if (a.foo != null) {
<!INAPPLICABLE_CANDIDATE!>useInt<!>(b.foo)
}
if (a.foo != null) {
<!INAPPLICABLE_CANDIDATE!>useInt<!>(foo)
}
if (this.foo != null) {
useInt(foo)
}
if (foo != null) {
useInt(this.foo)
}
}
fun useInt(i: Int) = i
}