[FE] KT-50878 Prohibit using contextual declarations without -Xcontext-receivers
This commit is contained in:
committed by
teamcity
parent
c93594331b
commit
a86b4d767e
+25
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -5,6 +5,17 @@ fun f(g: <!UNSUPPORTED_FEATURE!>context(Any)<!> () -> Unit, value: Any): <!UNSUP
|
||||
return value as (<!UNSUPPORTED_FEATURE!>context(A)<!> () -> Unit)
|
||||
}
|
||||
|
||||
fun f(g: () -> Unit, value: Any) : () -> Unit {
|
||||
return g
|
||||
}
|
||||
|
||||
<!UNSUPPORTED_FEATURE!>context(Any)<!>
|
||||
fun sameAsFWithoutNonContextualCounterpart(g: () -> Unit, value: Any) : () -> Unit {
|
||||
return g
|
||||
}
|
||||
|
||||
<!UNSUPPORTED_FEATURE!>context(Any)<!> val p get() = 42
|
||||
|
||||
<!UNSUPPORTED_FEATURE!>context(String, Int)<!>
|
||||
class A {
|
||||
<!UNSUPPORTED_FEATURE!>context(Any)<!>
|
||||
@@ -12,4 +23,17 @@ class A {
|
||||
|
||||
<!UNSUPPORTED_FEATURE!>context(String, Int)<!>
|
||||
fun m() {}
|
||||
}
|
||||
|
||||
fun useWithContextReceivers() {
|
||||
with(42) {
|
||||
with("") {
|
||||
f({}, 42)
|
||||
<!UNSUPPORTED_CONTEXTUAL_DECLARATION_CALL!>sameAsFWithoutNonContextualCounterpart({}, 42)<!>
|
||||
<!UNSUPPORTED_CONTEXTUAL_DECLARATION_CALL!>p<!>
|
||||
val a = <!UNSUPPORTED_CONTEXTUAL_DECLARATION_CALL!>A()<!>
|
||||
a.<!UNSUPPORTED_CONTEXTUAL_DECLARATION_CALL!>p<!>
|
||||
a.<!UNSUPPORTED_CONTEXTUAL_DECLARATION_CALL!>m()<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -1,6 +1,10 @@
|
||||
package
|
||||
|
||||
context(kotlin.Any) public val p: kotlin.Int
|
||||
public fun f(/*0*/ g: () -> kotlin.Unit, /*1*/ value: kotlin.Any): () -> kotlin.Unit
|
||||
context(kotlin.Any) public fun f(/*0*/ g: context(kotlin.Any) () -> kotlin.Unit, /*1*/ value: kotlin.Any): context(A) () -> kotlin.Unit
|
||||
context(kotlin.Any) public fun sameAsFWithoutNonContextualCounterpart(/*0*/ g: () -> kotlin.Unit, /*1*/ value: kotlin.Any): () -> kotlin.Unit
|
||||
public fun useWithContextReceivers(): kotlin.Unit
|
||||
|
||||
context(kotlin.String, kotlin.Int) public final class A {
|
||||
public constructor A()
|
||||
|
||||
Reference in New Issue
Block a user