CommonSupertypes support for flexible types

This commit is contained in:
Andrey Breslav
2014-08-25 12:15:31 +04:00
parent 583694a450
commit e232697da1
5 changed files with 74 additions and 5 deletions
@@ -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!!