Files
kotlin-fork/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/approximation.kt
T
Denis.Zharkov 0d070f8ba9 K2: Fix processing inference lower bound NullableType <: T & Any
Previously, it was led to plainly adding NullableType <: T constraint
which silently led to successful call completion.
What is suggested is just marking such initial constraint
as unsuccessful.

In K1, the error was reported just via additional type checking
mechanism being run after call completion.

^KT-58665 Fixed
2023-06-07 09:42:55 +00:00

16 lines
404 B
Kotlin
Vendored

// FIR_IDENTICAL
// !LANGUAGE: +DefinitelyNonNullableTypes
fun <T> foo(x: T, y: T & Any) = x!!
fun main() {
foo<String>("", "").length
foo<String>("", <!NULL_FOR_NONNULL_TYPE!>null<!>).length
foo<String?>(null, "").length
foo<String?>(null, <!NULL_FOR_NONNULL_TYPE!>null<!>).length
foo("", "").length
foo("", <!NULL_FOR_NONNULL_TYPE!>null<!>).length
foo(null, "").length
}