[FIR] resolve delegate field return type in correct scope

We should resolve it in the same way as delegate constructor call
to avoid access to nested class scopes

^KT-63522 Fixed
^KT-63042
This commit is contained in:
Dmitrii Gridin
2023-11-16 17:51:16 +01:00
committed by Space Team
parent ab6b3a6047
commit 0b253dc815
31 changed files with 362 additions and 231 deletions
@@ -9,7 +9,7 @@ FILE: nestedNameClash.kt
}
)
R|<local>/data|.R|second/Base.foo|()
R|<local>/data|.R|second/MyClass.foo|()
}
public abstract interface Base : R|kotlin/Any| {
public open fun foo(): R|kotlin/Unit| {
@@ -21,7 +21,7 @@ FILE: nestedNameClash.kt
super<R|kotlin/Any|>()
}
private final field $$delegate_0: R|second/MyClass.Base| = R|<local>/prop|
private final field $$delegate_0: R|second/Base| = R|<local>/prop|
public final val prop: R|second/Base| = R|<local>/prop|
public get(): R|second/Base|
@@ -9,7 +9,7 @@ FILE: nestedNameClash2.kt
}
)
R|<local>/data|.R|SubstitutionOverride<second/MyClass.foo: R|kotlin/Unit|>|()
R|<local>/data|.R|second/MyClass.foo|()
}
public abstract interface Base<A> : R|kotlin/Any| {
public open fun foo(): R|kotlin/Unit| {
@@ -21,7 +21,7 @@ FILE: nestedNameClash2.kt
super<R|kotlin/Any|>()
}
private final field $$delegate_0: R|second/MyClass.Base<second/Base<kotlin/Int>>| = R|<local>/prop|
private final field $$delegate_0: R|second/Base<second/Base<kotlin/Int>>| = R|<local>/prop|
public final val prop: R|second/Base<second/Base<kotlin/Int>>| = R|<local>/prop|
public get(): R|second/Base<second/Base<kotlin/Int>>|
@@ -1,15 +0,0 @@
// FIR_DUMP
package second
fun main() {
val data = MyClass(object : Base<Base<Int>> {})
data.foo()
}
interface Base<A> {
fun foo() {}
}
class MyClass(val prop: second.Base<second.Base<Int>>): Base<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Base<Int>><!> by prop {
interface Base
}
@@ -1,4 +1,4 @@
FILE: nestedNameClash3.fir.kt
FILE: nestedNameClash3.kt
package second
public final fun main(): R|kotlin/Unit| {
@@ -9,7 +9,7 @@ FILE: nestedNameClash3.fir.kt
}
)
R|<local>/data|.R|SubstitutionOverride<second/MyClass.foo: R|kotlin/Unit|>|()
R|<local>/data|.R|second/MyClass.foo|()
}
public abstract interface Base<A> : R|kotlin/Any| {
public open fun foo(): R|kotlin/Unit| {
@@ -21,7 +21,7 @@ FILE: nestedNameClash3.fir.kt
super<R|kotlin/Any|>()
}
private final field $$delegate_0: <ERROR TYPE REF: Wrong number of type arguments> = R|<local>/prop|
private final field $$delegate_0: R|second/Base<second/Base<kotlin/Int>>| = R|<local>/prop|
public final val prop: R|second/Base<second/Base<kotlin/Int>>| = R|<local>/prop|
public get(): R|second/Base<second/Base<kotlin/Int>>|
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FIR_DUMP
package second
@@ -24,7 +24,7 @@ FILE: nestedNameClashAndAnnotations.kt
super<R|kotlin/Any|>()
}
private final field $$delegate_0: R|@R|second/Anno|(i = Int(3).R|kotlin/Int.plus|(R|second/outer|)) second/MyClass.Base<@R|second/Anno|(i = Int(4).R|kotlin/Int.plus|(R|second/outer|)) second/Base<@R|second/Anno|(i = Int(5).R|kotlin/Int.plus|(R|second/outer|)) kotlin/Int>>| = R|<local>/prop|
private final field $$delegate_0: R|@R|second/Anno|(i = Int(3).R|kotlin/Int.plus|(R|second/outer|)) second/Base<@R|second/Anno|(i = Int(4).R|kotlin/Int.plus|(R|second/outer|)) second/Base<@R|second/Anno|(i = Int(5).R|kotlin/Int.plus|(R|second/outer|)) kotlin/Int>>| = R|<local>/prop|
public final val prop: R|@R|second/Anno|(i = Int(0).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(1).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(2).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) kotlin/Int>>| = R|<local>/prop|
public get(): R|@R|second/Anno|(i = Int(0).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(1).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(2).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) kotlin/Int>>|
@@ -24,7 +24,7 @@ FILE: nestedNameClashAndAnnotations.reversed.kt
super<R|kotlin/Any|>()
}
private final field $$delegate_0: R|@R|second/Anno|(i = IntegerLiteral(3).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) second/MyClass.Base<@R|second/Anno|(i = IntegerLiteral(4).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) second/Base<@R|second/Anno|(i = IntegerLiteral(5).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) kotlin/Int>>| = R|<local>/prop|
private final field $$delegate_0: R|@R|second/Anno|(i = IntegerLiteral(3).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) second/Base<@R|second/Anno|(i = IntegerLiteral(4).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) second/Base<@R|second/Anno|(i = IntegerLiteral(5).<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.outer|)) kotlin/Int>>| = R|<local>/prop|
public final val prop: R|@R|second/Anno|(i = Int(0).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(1).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(2).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) kotlin/Int>>| = R|<local>/prop|
public get(): R|@R|second/Anno|(i = Int(0).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(1).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) second/Base<@R|second/Anno|(i = Int(2).R|kotlin/Int.plus|(this@R|second/MyClass.Companion|.R|second/MyClass.Companion.inner|)) kotlin/Int>>|
@@ -2,7 +2,7 @@
interface I<F, G, H>
class A(impl: Interface) : <!UNRESOLVED_REFERENCE!>Nested<!>(), <!UNRESOLVED_REFERENCE!>Interface<!> by impl, <!UNRESOLVED_REFERENCE!>Inner<!>, I<<!UNRESOLVED_REFERENCE!>Nested<!>, <!UNRESOLVED_REFERENCE!>Interface<!>, <!UNRESOLVED_REFERENCE!>Inner<!>> {
class A(impl: Interface) : <!UNRESOLVED_REFERENCE!>Nested<!>(), <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Interface<!> by impl, <!UNRESOLVED_REFERENCE!>Inner<!>, I<<!UNRESOLVED_REFERENCE!>Nested<!>, <!UNRESOLVED_REFERENCE!>Interface<!>, <!UNRESOLVED_REFERENCE!>Inner<!>> {
class Nested
@@ -3,7 +3,7 @@ interface I<F, G>
val aImpl: A.Interface
get() = null!!
object A : <!UNRESOLVED_REFERENCE!>Nested<!>(), <!UNRESOLVED_REFERENCE!>Interface<!> by aImpl, I<<!UNRESOLVED_REFERENCE!>Nested<!>, <!UNRESOLVED_REFERENCE!>Interface<!>> {
object A : <!UNRESOLVED_REFERENCE!>Nested<!>(), <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>Interface<!> by aImpl, I<<!UNRESOLVED_REFERENCE!>Nested<!>, <!UNRESOLVED_REFERENCE!>Interface<!>> {
class Nested