Use upper bound aware type approximator for intersection types inside sam types in contravariant positions to build proper types in terms of subtyping
This commit is contained in:
committed by
TeamCityServer
parent
6a78e0a10c
commit
4aeabb6b0f
+21
@@ -0,0 +1,21 @@
|
||||
interface X
|
||||
interface Z
|
||||
|
||||
interface A : X, Z
|
||||
interface B : X, Z
|
||||
|
||||
fun interface IFoo<T> where T : X, T : Z {
|
||||
fun accept(t: T)
|
||||
}
|
||||
|
||||
fun <T> sel(x: T, y: T) = x
|
||||
|
||||
class G<T> where T: X, T: Z {
|
||||
fun check(x: IFoo<in T>) {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val g = sel(G<A>(), G<B>()) // g: G<out { X & Z }>
|
||||
g.check {} // (*) target SAM type: IFoo<{ X & Z }> (TODO: report a compile time error for this case)
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user