FIR: Fix overload resolution with context receivers

This commit is contained in:
Denis.Zharkov
2022-03-24 13:44:30 +03:00
committed by teamcity
parent 4349060db1
commit dfc736161a
9 changed files with 23 additions and 40 deletions
@@ -10,9 +10,9 @@ fun f(): Unit<!> = TODO()
fun f(): Unit<!> = TODO()
fun test(a: A, b: B) {
with(a) {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
with(b) {
f()
<!ARGUMENT_TYPE_MISMATCH!><!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>()<!>
}
}
}
@@ -1,14 +0,0 @@
// !LANGUAGE: +ContextReceivers
class Context
<!CONFLICTING_OVERLOADS!>context(Context)
fun f(): String<!> = TODO()
<!CONFLICTING_OVERLOADS!>fun f(): Any<!> = TODO()
fun test() {
with(Context()) {
f().length
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +ContextReceivers
class Context
@@ -1,17 +0,0 @@
// !LANGUAGE: +ContextReceivers
<!CONFLICTING_OVERLOADS!>context(Int, String)
fun foo(): Int<!> {
return this@Int + 42
}
<!CONFLICTING_OVERLOADS!>context(Int)
fun foo(): Int<!> {
return this@Int + 42
}
fun test() {
with(42) {
foo()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +ContextReceivers
context(Int, String)
@@ -5,16 +5,16 @@ class B(val b: Any)
class C(val c: Any)
context(A<String>) fun A<Int>.f() {
this@A.a.length
this@A.a.<!UNRESOLVED_REFERENCE!>length<!>
}
<!CONFLICTING_OVERLOADS!>context(A<String>, B) fun f()<!> {
context(A<String>, B) fun f() {
this@A.a.length
this@B.b
<!NO_THIS!>this<!>
}
<!CONFLICTING_OVERLOADS!>context(A<Int>, A<String>, B) fun f()<!> {
context(A<Int>, A<String>, B) fun f() {
this@A.a.length
this@B.b
<!NO_THIS!>this<!>
@@ -28,7 +28,7 @@ class A {
fun useWithContextReceivers() {
with(42) {
with("") {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>({}, 42)
f({}, 42)
sameAsFWithoutNonContextualCounterpart({}, 42)
p
val a = A()