NI: intersect DFI types before capturing

^KT-37887 Fixed
This commit is contained in:
Victor Petukhov
2020-05-14 13:43:30 +03:00
parent 5a7ceec985
commit 73dec25eb1
15 changed files with 141 additions and 32 deletions
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNCHECKED_CAST -UNUSED_DESTRUCTURED_PARAMETER_ENTRY -USELESS_CAST -UNUSED_PARAMETER -UNUSED_EXPRESSION
class Inv<T>(val y: T)
fun <K> takeTwoInv(x: Inv<K>, y: Inv<K>) = x.y
fun <K> takeTwoInvOut(x: Inv<out K>, y: Inv<out K>) : K = x.y
fun test1(y: Any) {
y as Map<String, Any?>
y as Map<*, *>
y.forEach { (k: String, u: Any?) -> }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.Map<kotlin.String, kotlin.Any?> & kotlin.Any")!>y<!>
}
fun test2(x: Any, y: Inv<String>) {
x as Inv<String>
x as Inv<out CharSequence>
val z = takeTwoInv(x, y)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>z<!>
}
fun test3(x: Any, y: Inv<String>) {
x as Inv<out CharSequence>
x as Inv<String>
val z = takeTwoInvOut(x, y)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>z<!>
}
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNCHECKED_CAST -UNUSED_DESTRUCTURED_PARAMETER_ENTRY -USELESS_CAST -UNUSED_PARAMETER -UNUSED_EXPRESSION
class Inv<T>(val y: T)
fun <K> takeTwoInv(x: Inv<K>, y: Inv<K>) = x.y
fun <K> takeTwoInvOut(x: Inv<out K>, y: Inv<out K>) : K = x.y
fun test1(y: Any) {
y as Map<String, Any?>
y as Map<*, *>
<!DEBUG_INFO_SMARTCAST!>y<!>.forEach { (k: String, u: Any?) -> }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.collections.Map<*, *> & kotlin.collections.Map<kotlin.String, kotlin.Any?>")!>y<!>
}
fun test2(x: Any, y: Inv<String>) {
x as Inv<String>
x as Inv<out CharSequence>
val z = takeTwoInv(<!DEBUG_INFO_SMARTCAST!>x<!>, y)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>z<!>
}
fun test3(x: Any, y: Inv<String>) {
x as Inv<out CharSequence>
x as Inv<String>
val z = takeTwoInvOut(<!DEBUG_INFO_SMARTCAST!>x<!>, y)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>z<!>
}
@@ -0,0 +1,15 @@
package
public fun </*0*/ K> takeTwoInv(/*0*/ x: Inv<K>, /*1*/ y: Inv<K>): K
public fun </*0*/ K> takeTwoInvOut(/*0*/ x: Inv<out K>, /*1*/ y: Inv<out K>): K
public fun test1(/*0*/ y: kotlin.Any): kotlin.Unit
public fun test2(/*0*/ x: kotlin.Any, /*1*/ y: Inv<kotlin.String>): kotlin.Unit
public fun test3(/*0*/ x: kotlin.Any, /*1*/ y: Inv<kotlin.String>): kotlin.Unit
public final class Inv</*0*/ T> {
public constructor Inv</*0*/ T>(/*0*/ y: T)
public final val y: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}