Reuse captured arguments for flexible type's bounds properly, by equality of type constructors modulo mutability and type argument
^KT-43630 Fixed
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: Bar.java
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// SKIP_TXT
|
||||
|
||||
public class Bar<K, N> { }
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo<P> extends Bar<Integer, Integer> {
|
||||
public static final Bar bar = null;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <P> takeFoo(foo: Foo<P>) {}
|
||||
|
||||
fun main(x: Foo<*>?) {
|
||||
val y = Foo.bar
|
||||
if (y !is Foo<*>?) return
|
||||
if (y == null) return
|
||||
if (x != y) return
|
||||
takeFoo(x) // Here we capture `{Bar<Any!, Any!> & Foo<*>}..Foo<*>?`
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: Bar.java
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// SKIP_TXT
|
||||
|
||||
public class Bar<K, N> { }
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo<P> extends Bar<Integer, Integer> {
|
||||
public static final Bar bar = null;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <P> takeFoo(foo: Foo<P>) {}
|
||||
|
||||
fun main(x: Foo<*>?) {
|
||||
val y = Foo.bar
|
||||
if (y !is Foo<*>?) return
|
||||
if (y == null) return
|
||||
if (x != y) return
|
||||
takeFoo(<!DEBUG_INFO_SMARTCAST!>x<!>) // Here we capture `{Bar<Any!, Any!> & Foo<*>}..Foo<*>?`
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// FULL_JDK
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// SKIP_TXT
|
||||
|
||||
// FILE: Bar.java
|
||||
|
||||
public class Bar<K, N> { }
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Foo<P> extends Bar<Integer, Integer> {
|
||||
public static final List<?> bar = null;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <P> takeFoo(foo: Foo<P>) {}
|
||||
|
||||
fun main(x: Foo<*>?) {
|
||||
val y = Foo.bar
|
||||
if (y !is Foo<*>?) return
|
||||
if (y == null) return
|
||||
if (x != y) return
|
||||
// Here we capture `({Foo<*> & MutableList<*>}..{Foo<*>? & List<*>?})`
|
||||
// `*` inside `MutableList` and `List` have to become the same captured type
|
||||
takeFoo(x)
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// FULL_JDK
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// SKIP_TXT
|
||||
|
||||
// FILE: Bar.java
|
||||
|
||||
public class Bar<K, N> { }
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Foo<P> extends Bar<Integer, Integer> {
|
||||
public static final List<?> bar = null;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <P> takeFoo(foo: Foo<P>) {}
|
||||
|
||||
fun main(x: Foo<*>?) {
|
||||
val y = Foo.bar
|
||||
if (y !is Foo<*>?) return
|
||||
if (y == null) return
|
||||
if (x != y) return
|
||||
// Here we capture `({Foo<*> & MutableList<*>}..{Foo<*>? & List<*>?})`
|
||||
// `*` inside `MutableList` and `List` have to become the same captured type
|
||||
takeFoo(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||
}
|
||||
Reference in New Issue
Block a user