CommonSupertypes support for flexible types
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: p/Super.java
|
||||
|
||||
package p;
|
||||
|
||||
public interface Super {
|
||||
|
||||
}
|
||||
|
||||
// FILE: p/Sub.java
|
||||
|
||||
package p;
|
||||
|
||||
public interface Sub extends Super {}
|
||||
|
||||
// FILE: p/Other.java
|
||||
|
||||
package p;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Other {
|
||||
|
||||
public static Sub sub;
|
||||
|
||||
public static Collection<Sub> subs;
|
||||
public static Collection<Super> supers;
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
fun test() {
|
||||
val col = if (1 < 2) Other.subs else Other.supers
|
||||
col.foo()
|
||||
}
|
||||
|
||||
fun <T: Super> Collection<T>.foo(): T = null!!
|
||||
fun listOf<T>(t: T): List<T> = null!!
|
||||
Reference in New Issue
Block a user