0d070f8ba9
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
16 lines
416 B
Kotlin
Vendored
16 lines
416 B
Kotlin
Vendored
// FIR_IDENTICAL
|
|
// !LANGUAGE: +DefinitelyNonNullableTypes
|
|
|
|
fun <T> foo(x: T, y: T & Any): T & Any = x ?: y
|
|
|
|
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
|
|
}
|