[FIR] During resolve, set correctly property reference type in delegate

This commit is contained in:
Mikhail Glukhikh
2020-03-31 17:11:49 +03:00
parent 58e00400f1
commit 036b6c63f6
42 changed files with 181 additions and 73 deletions
@@ -5,10 +5,10 @@ import kotlin.reflect.KProperty
class A
class D {
val c: Int by IncorrectThis<A>()
val c: Int by <!UNRESOLVED_REFERENCE!>IncorrectThis<A>()<!>
}
val cTopLevel: Int by IncorrectThis<A>()
val cTopLevel: Int by <!UNRESOLVED_REFERENCE!>IncorrectThis<A>()<!>
class IncorrectThis<T> {
fun <R> get(t: Any?, p: KProperty<*>): Int {
@@ -4,10 +4,10 @@ package foo
import kotlin.reflect.KProperty
open class A {
val B.w: Int by MyProperty()
val B.w: Int by <!INAPPLICABLE_CANDIDATE!>MyProperty()<!>
}
val B.r: Int by MyProperty()
val B.r: Int by <!INAPPLICABLE_CANDIDATE!>MyProperty()<!>
val A.e: Int by MyProperty()
@@ -5,7 +5,7 @@ package test
import first.*
import second.*
val a12 by A()
val a12 by <!AMBIGUITY!>A()<!>
// FILE: first.kt
package first
@@ -8,4 +8,4 @@ class ValueWrapper()
fun setValue(v: Int) { backingValue = v }
}
val foo by ValueWrapper()
val foo by <!INAPPLICABLE_CANDIDATE!>ValueWrapper()<!>
@@ -1,3 +1,3 @@
val a: Int by A()
val a: Int by <!UNRESOLVED_REFERENCE!>A()<!>
class A
@@ -5,7 +5,7 @@
import kotlin.reflect.KProperty
class B {
val c by <!INAPPLICABLE_CANDIDATE!>Delegate<!>(<!UNRESOLVED_REFERENCE!>ag<!>)
val c by <!UNRESOLVED_REFERENCE!><!INAPPLICABLE_CANDIDATE!>Delegate<!>(<!UNRESOLVED_REFERENCE!>ag<!>)<!>
}
class Delegate<T: Any>(val init: T) {
@@ -5,5 +5,5 @@ object T1 {
operator fun Long.getValue(receiver: String, p: Any): Double = 1.0
val String.test1 by 1
val test2 by 1
val test2 by <!INAPPLICABLE_CANDIDATE!>1<!>
}
@@ -10,5 +10,5 @@ object T2 {
operator fun <T> Foo<T>.getValue(receiver: String, p: Any?): T = TODO()
val String.test1: String by delegate()
val test2: String by delegate()
val test2: String by <!INAPPLICABLE_CANDIDATE!>delegate()<!>
}
@@ -4,12 +4,12 @@
import kotlin.reflect.KProperty
val a by a
val a by <!UNRESOLVED_REFERENCE!>a<!>
val b by Delegate(b)
val c by d
val d by c
val c by <!UNRESOLVED_REFERENCE!>d<!>
val d by <!UNRESOLVED_REFERENCE!>c<!>
class Delegate(i: Int) {
operator fun getValue(t: Any?, p: KProperty<*>): Int {
@@ -5,7 +5,7 @@ import kotlin.reflect.KProperty
val Int.a by Delegate(this)
class A {
val Int.a by <!INAPPLICABLE_CANDIDATE!>Delegate<!>(this)
val Int.a by <!UNRESOLVED_REFERENCE!><!INAPPLICABLE_CANDIDATE!>Delegate<!>(this)<!>
}
class Delegate(i: Int) {
@@ -4,7 +4,7 @@
import kotlin.reflect.KProperty
class A {
var a: Int by Delegate()
var a: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
}
var aTopLevel: Int by Delegate()
@@ -4,10 +4,10 @@
import kotlin.reflect.KProperty
class A {
var a: Int by Delegate()
var a: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
}
var aTopLevel: Int by Delegate()
var aTopLevel: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
class Delegate {
fun getValue(t: Nothing, p: KProperty<*>): Int {
@@ -3,7 +3,7 @@
import kotlin.reflect.KProperty
class A {
val c: Int by Delegate()
val c: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
}
class Delegate {
@@ -5,10 +5,10 @@ import kotlin.reflect.KProperty
class A
class B {
val b: Int by Delegate<A>()
val b: Int by <!INAPPLICABLE_CANDIDATE!>Delegate<A>()<!>
}
val bTopLevel: Int by Delegate<A>()
val bTopLevel: Int by <!INAPPLICABLE_CANDIDATE!>Delegate<A>()<!>
class C {
val c: Int by Delegate<C>()
@@ -4,10 +4,10 @@
import kotlin.reflect.KProperty
class B {
val b: Int by Delegate()
val b: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
}
val bTopLevel: Int by Delegate()
val bTopLevel: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
class A
@@ -3,10 +3,10 @@
import kotlin.reflect.KProperty
class A {
val a: Int by Delegate()
val a: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
}
val aTopLevel: Int by Delegate()
val aTopLevel: Int by <!INAPPLICABLE_CANDIDATE!>Delegate()<!>
class Delegate {
fun getValue(t: Any?, p: KProperty<*>, a: Int): Int {