06ee768c6a
Before this commit, we used type after smart cast both for original FirThisReceiverExpression and for wrapping FirExpressionWithSmartCast. However, this makes FIR2IR implicit cast generator work incorrectly (it decides not to insert implicit cast because original type is the same). After this commit, expressions have different types and implicit cast generator works properly.
54 lines
1.4 KiB
Kotlin
Vendored
54 lines
1.4 KiB
Kotlin
Vendored
// !LANGUAGE: +NewInference
|
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
|
// SKIP_TXT
|
|
|
|
// TESTCASE NUMBER: 1
|
|
fun case_1(vararg x: Int?) {
|
|
if (x != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<out kotlin.Int?> & kotlin.Array<out kotlin.Int?>")!>x<!>
|
|
x[0]
|
|
}
|
|
}
|
|
|
|
// TESTCASE NUMBER: 2
|
|
fun case_2(vararg x: Int?) {
|
|
x[0].apply {
|
|
if (this != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?")!>this<!>
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?")!>this<!>.inv()
|
|
}
|
|
}
|
|
|
|
x[0].also {
|
|
if (it != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?")!>it<!>
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?")!>it<!>.inv()
|
|
}
|
|
}
|
|
}
|
|
|
|
// TESTCASE NUMBER: 3
|
|
fun <T> case_3(vararg x: T?) {
|
|
if (x != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<out T?> & kotlin.Array<out T?>")!>x<!>
|
|
x[0]
|
|
}
|
|
}
|
|
|
|
// TESTCASE NUMBER: 4
|
|
fun <T : Number?> case_4(vararg x: T?) {
|
|
x[0].apply {
|
|
if (this != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("T?!! & T?")!>this<!>
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("T?!! & T?")!>this<!>.toByte()
|
|
}
|
|
}
|
|
|
|
x[0].also {
|
|
if (it != null) {
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("T?!! & T?")!>it<!>
|
|
<!DEBUG_INFO_EXPRESSION_TYPE("T?!! & T?")!>it<!>.toByte()
|
|
}
|
|
}
|
|
}
|