[FE] KT-50878 Prohibit using contextual declarations without -Xcontext-receivers

This commit is contained in:
Anastasia.Shadrina
2022-01-20 18:03:51 +07:00
committed by teamcity
parent c93594331b
commit a86b4d767e
8 changed files with 70 additions and 5 deletions
@@ -5,6 +5,17 @@ fun f(g: context(Any) () -> Unit, value: Any): context(A) () -> Unit {
return value as (context(A) () -> Unit)
}
fun f(g: () -> Unit, value: Any) : () -> Unit {
return g
}
context(Any)
fun sameAsFWithoutNonContextualCounterpart(g: () -> Unit, value: Any) : () -> Unit {
return g
}
context(Any) val p get() = 42
context(String, Int)
class A {
context(Any)
@@ -12,4 +23,17 @@ class A {
context(String, Int)
fun m() {}
}
}
fun useWithContextReceivers() {
with(42) {
with("") {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>({}, 42)
sameAsFWithoutNonContextualCounterpart({}, 42)
p
val a = A()
a.p
a.m()
}
}
}