Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/noErrorCheckForPackageLevelVal.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

25 lines
376 B
Kotlin
Vendored

//FILE: bar.kt
package bar
val i: Int? = 2
//FILE: foo.kt
package foo
val i: Int? = 1
class A(val i: Int?) {
fun testUseFromClass() {
if (foo.i != null) {
<!INAPPLICABLE_CANDIDATE!>useInt<!>(i)
}
}
}
fun testUseFromOtherPackage() {
if (bar.i != null) {
<!INAPPLICABLE_CANDIDATE!>useInt<!>(i)
}
}
fun useInt(i: Int) = i