Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt
T
Victor Petukhov 775eb67219 NI: Add constraints which contain constraining type without projection
^KT-32243 Fixed
^KT-35172 Fixed
2019-12-02 19:42:18 +03:00

40 lines
1.0 KiB
Kotlin
Vendored

// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNCHECKED_CAST
interface ISample
fun <K> elvisSimple(x: K?, y: K): K = y
@Suppress("INVISIBLE_REFERENCE")
fun <K> elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y
fun <T : Number> materialize(): T? = null
fun <T> Any?.materialize(): T = null as T
fun test(nullableSample: ISample, any: Any) {
<!DEBUG_INFO_EXPRESSION_TYPE("ISample?")!>elvisSimple(
nullableSample,
<!DEBUG_INFO_EXPRESSION_TYPE("{ISample & Number}?")!>materialize()<!>
)<!>
elvisSimple(
<!DEBUG_INFO_EXPRESSION_TYPE("ISample?")!>elvisSimple(nullableSample, materialize())<!>,
any
)
elvisSimple(
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>elvisExact(nullableSample, materialize())<!>,
any
)
val a: String? = null
val x1: String? = run {
a ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>a?.materialize()<!>
}
val x2 = run {
a ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>a?.materialize()<!>
}
}