[FE] Implement temporary resolution algorithm

This commit is contained in:
Anastasiya Shadrina
2021-02-15 18:54:11 +07:00
committed by TeamCityServer
parent d923c95671
commit c34fe8d547
43 changed files with 800 additions and 24 deletions
@@ -0,0 +1,20 @@
class View
context(View) val Int.dp get() = 42 * this
fun View.f() {
123.dp
with(123) {
dp
}
}
fun Int.g(v: View) {
with(v) {
dp
}
}
fun h() {
123.dp
}
@@ -0,0 +1,20 @@
class View
context(View) val Int.dp get() = 42 * this
fun View.f() {
123.dp
with(123) {
dp
}
}
fun Int.g(v: View) {
with(v) {
dp
}
}
fun h() {
123.<!NO_CONTEXT_RECEIVER!>dp<!>
}
@@ -0,0 +1,13 @@
package
public val kotlin.Int.dp: kotlin.Int
public fun h(): kotlin.Unit
public fun View.f(): kotlin.Unit
public fun kotlin.Int.g(/*0*/ v: View): kotlin.Unit
public final class View {
public constructor View()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,18 @@
class A {
fun h1() {}
}
class B {
fun h2() {}
}
fun B.foo() {
<!UNRESOLVED_REFERENCE!>h1<!>()
h2()
}
context(A)
fun B.bar() {
<!UNRESOLVED_REFERENCE!>h1<!>()
h2()
}
@@ -0,0 +1,18 @@
class A {
fun h1() {}
}
class B {
fun h2() {}
}
fun B.foo() {
<!UNRESOLVED_REFERENCE!>h1<!>()
h2()
}
context(A)
fun B.bar() {
h1()
h2()
}
@@ -0,0 +1,20 @@
package
public fun B.bar(): kotlin.Unit
public fun B.foo(): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun h1(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun h2(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,48 @@
interface Lazy<T>
context(Lazy<Int>, Lazy<CharSequence>)
fun test1() {}
context(Lazy<T>)
fun <T> Lazy<Int>.test2() {}
context(Lazy<Lazy<T>>)
fun <T> Lazy<Int>.test3() {}
fun <T> f(lazy1: Lazy<Int>, lazy2: Lazy<CharSequence>, lazyT: Lazy<T>, lazyLazyT: Lazy<Lazy<T>>) {
with(lazy1) {
with(lazy2) {
test1()
test2()
test3()
}
}
with(lazy2) {
with(lazy1) {
test1()
test2()
test3()
}
}
with(lazyT) {
with(lazy1) {
test1()
test2()
test3()
}
}
with(lazyLazyT) {
with(lazy1) {
test1()
test2()
test3()
}
}
with(lazy1) {
with(lazyLazyT) {
test1()
test2()
test3()
}
}
}
@@ -0,0 +1,48 @@
interface Lazy<T>
context(Lazy<Int>, Lazy<CharSequence>)
fun test1() {}
context(Lazy<T>)
fun <T> Lazy<Int>.test2() {}
context(Lazy<Lazy<T>>)
fun <T> Lazy<Int>.test3() {}
fun <T> f(lazy1: Lazy<Int>, lazy2: Lazy<CharSequence>, lazyT: Lazy<T>, lazyLazyT: Lazy<Lazy<T>>) {
with(lazy1) {
with(lazy2) {
test1()
test2()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>test3<!>()
}
}
with(lazy2) {
with(lazy1) {
test1()
test2()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>test3<!>()
}
}
with(lazyT) {
with(lazy1) {
<!NO_CONTEXT_RECEIVER!>test1()<!>
test2()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>test3<!>()
}
}
with(lazyLazyT) {
with(lazy1) {
<!NO_CONTEXT_RECEIVER!>test1()<!>
test2()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>test3<!>()
}
}
with(lazy1) {
with(lazyLazyT) {
<!NO_CONTEXT_RECEIVER!>test1()<!>
test2()
test3()
}
}
}
@@ -0,0 +1,12 @@
package
public fun </*0*/ T> f(/*0*/ lazy1: Lazy<kotlin.Int>, /*1*/ lazy2: Lazy<kotlin.CharSequence>, /*2*/ lazyT: Lazy<T>, /*3*/ lazyLazyT: Lazy<Lazy<T>>): kotlin.Unit
public fun test1(): kotlin.Unit
public fun </*0*/ T> Lazy<kotlin.Int>.test2(): kotlin.Unit
public fun </*0*/ T> Lazy<kotlin.Int>.test3(): kotlin.Unit
public interface Lazy</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,35 @@
class A {
val a = 1
}
class B {
val b = 2
}
class C {
val c = 3
}
context(A, B) fun C.f() {}
fun main(a: A, b: B, c: C) {
with(a) {
with(b) {
with(c) {
f()
}
}
}
with(b) {
with(c) {
with(a) {
f()
}
}
}
with(a) {
with(c) {
f()
}
}
}
@@ -0,0 +1,35 @@
class A {
val a = 1
}
class B {
val b = 2
}
class C {
val c = 3
}
context(A, B) fun C.f() {}
fun main(a: A, b: B, c: C) {
with(a) {
with(b) {
with(c) {
f()
}
}
}
with(b) {
with(c) {
with(a) {
f()
}
}
}
with(a) {
with(c) {
<!NO_CONTEXT_RECEIVER!>f()<!>
}
}
}
@@ -0,0 +1,28 @@
package
public fun main(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit
public fun C.f(): kotlin.Unit
public final class A {
public constructor A()
public final val a: kotlin.Int = 1
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
public final val b: kotlin.Int = 2
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C {
public constructor C()
public final val c: kotlin.Int = 3
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,18 @@
class A
class B
class C
context(A) fun B.f() {}
context(A) fun B.g() {
f()
}
context(A) fun C.h() {
<!INAPPLICABLE_CANDIDATE!>f<!>()
}
fun A.q(b: B) {
with(b) {
f()
}
<!INAPPLICABLE_CANDIDATE!>f<!>()
}
@@ -0,0 +1,18 @@
class A
class B
class C
context(A) fun B.f() {}
context(A) fun B.g() {
f()
}
context(A) fun C.h() {
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>f<!>()
}
fun A.q(b: B) {
with(b) {
f()
}
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>f<!>()
}
@@ -0,0 +1,27 @@
package
public fun B.f(): kotlin.Unit
public fun B.g(): kotlin.Unit
public fun C.h(): kotlin.Unit
public fun A.q(/*0*/ b: B): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface NumberOperations {
fun Number.plus(other: Number): Number
}
class Matrix
context(NumberOperations) fun Matrix.plus(other: Matrix): Matrix = TODO()
fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) {
m1.plus(m2)
m2.plus(m1)
}
@@ -0,0 +1,18 @@
package
public fun Matrix.plus(/*0*/ other: Matrix): Matrix
public fun NumberOperations.plusMatrix(/*0*/ m1: Matrix, /*1*/ m2: Matrix): kotlin.Unit
public final class Matrix {
public constructor Matrix()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface NumberOperations {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public abstract fun kotlin.Number.plus(/*0*/ other: kotlin.Number): kotlin.Number
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A
class B<X>(val x: X)
context(T)
fun <T> T.f(t: B<T>) {}
fun Int.main(a: A, b: B<String>) {
a.<!INAPPLICABLE_CANDIDATE!>f<!>(b)
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A
class B<X>(val x: X)
context(T)
fun <T> T.f(t: B<T>) {}
fun Int.main(a: A, b: B<String>) {
a.f(<!TYPE_MISMATCH, TYPE_MISMATCH!>b<!>)
}
@@ -0,0 +1,19 @@
package
public fun </*0*/ T> T.f(/*0*/ t: B<T>): kotlin.Unit
public fun kotlin.Int.main(/*0*/ a: A, /*1*/ b: B<kotlin.String>): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B</*0*/ X> {
public constructor B</*0*/ X>(/*0*/ x: X)
public final val x: X
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun <T> listOf(vararg e: T): List<T> = null!!
class A<T>
context(List<T>)
fun <T> A<T>.f() {}
fun main() {
with(listOf(1, 2, 3)) {
A<Int>().f()
}
with(listOf("1", "2", "3")) {
A<Int>().f()
}
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun <T> listOf(vararg e: T): List<T> = null!!
class A<T>
context(List<T>)
fun <T> A<T>.f() {}
fun main() {
with(listOf(1, 2, 3)) {
A<Int>().f()
}
with(listOf("1", "2", "3")) {
A<Int>().<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>f<!>()
}
}
@@ -0,0 +1,12 @@
package
public fun </*0*/ T> listOf(/*0*/ vararg e: T /*kotlin.Array<out T>*/): kotlin.collections.List<T>
public fun main(): kotlin.Unit
public fun </*0*/ T> A<T>.f(): kotlin.Unit
public final class A</*0*/ T> {
public constructor A</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,18 @@
open class A
class B
class C: A()
context(A)
fun B.f() {}
fun main() {
val b = B()
b.f()
with(A()) {
b.f()
}
with(C()) {
b.f()
}
}
@@ -0,0 +1,18 @@
open class A
class B
class C: A()
context(A)
fun B.f() {}
fun main() {
val b = B()
b.<!NO_CONTEXT_RECEIVER!>f()<!>
with(A()) {
b.f()
}
with(C()) {
b.f()
}
}
@@ -0,0 +1,25 @@
package
public fun main(): kotlin.Unit
public fun B.f(): kotlin.Unit
public open class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C : A {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,18 @@
class A
class B
class C
context(A)
fun B.f() {}
fun main() {
val b = B()
b.f()
with(A()) {
b.f()
}
with(C()) {
b.f()
}
}
@@ -0,0 +1,18 @@
class A
class B
class C
context(A)
fun B.f() {}
fun main() {
val b = B()
b.<!NO_CONTEXT_RECEIVER!>f()<!>
with(A()) {
b.f()
}
with(C()) {
b.<!NO_CONTEXT_RECEIVER!>f()<!>
}
}
@@ -0,0 +1,25 @@
package
public fun main(): kotlin.Unit
public fun B.f(): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}