[FIR] KT-59368 context receiver subtyping checker

This commit is contained in:
Tomas Husak
2023-11-29 16:52:01 +01:00
committed by Space Team
parent 3d77d09260
commit d7eb67a436
17 changed files with 181 additions and 268 deletions
@@ -0,0 +1,27 @@
FILE: contextReceiversSubtyping.kt
public abstract interface D : R|D1|, R|D2| {
}
public abstract interface D1 : R|kotlin/Any| {
}
public abstract interface D2 : R|kotlin/Any| {
}
context(R|T|, R|D2|)
public final fun <T : R|D1|, R|D2|> foo(): R|kotlin/Unit| {
}
public abstract interface Cov<out T> : R|kotlin/Any| {
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
}
context(R|Cov<T>|, R|Cov<B>|)
public final fun <T : R|A|> foo(): R|kotlin/Unit| {
}
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
// !LANGUAGE: +ContextReceivers
interface D: D1, D2 {}
interface D1 {}
interface D2 {}
<!SUBTYPING_BETWEEN_CONTEXT_RECEIVERS!>context(T, D2)<!>
fun <T> foo() where T: D1, T: D2 {}
interface Cov<out T> {}
class A {}
class B {}
// This sholdn't be an error since the type parameter is predetermined to be `A`,
// which causes that there can't be subtyping between the context receivers.
// However, the cheking is simplified because it is time-consuming process.
<!SUBTYPING_BETWEEN_CONTEXT_RECEIVERS!>context(Cov<T>, Cov<B>)<!>
fun <T: <!FINAL_UPPER_BOUND!>A<!>> foo() {}