K2: handle type parameter vs nested class conflict in body resolve properly
This commit does two things: - prioritize type parameter scopes against static scopes in body resolve (effectively it's a revert of KT-58028 fix) - consider type parameters as inapplicable callable, so during callable resolve we can go up the tower and still resolve to static scope This allows both KT-58028 and KT-63377 to work properly #KT-63377 Fixed
This commit is contained in:
committed by
Space Team
parent
4e938d852c
commit
83cfcc30c6
+1
-1
@@ -15,7 +15,7 @@ fun test() {
|
||||
|
||||
fun <T> bar() {
|
||||
val typeParameter_as_val = <!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>
|
||||
val typeParameter_as_fun = <!UNRESOLVED_REFERENCE!>T<!>()
|
||||
val typeParameter_as_fun = <!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>()
|
||||
|
||||
baz(<!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>)
|
||||
baz("$<!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>")
|
||||
|
||||
Vendored
+2
-2
@@ -91,11 +91,11 @@ FILE: companionPropertyAndTypeParameter.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?|
|
||||
public final val some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?<Type parameter test in qualified access>#|
|
||||
public get(): <ERROR TYPE REF: Type parameter test in qualified access>
|
||||
|
||||
public final fun f(): R|kotlin/Unit| {
|
||||
lval some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?|
|
||||
lval some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?<Type parameter test in qualified access>#|
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
// ISSUE: KT-58028, KT-63377
|
||||
// FIR_DUMP
|
||||
|
||||
class Owner<test> {
|
||||
companion object {
|
||||
val test = 12
|
||||
}
|
||||
|
||||
inner class I<test> {
|
||||
val some = <!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>test<!>
|
||||
|
||||
fun foo() {
|
||||
val some = <!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>test<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+4
-4
@@ -1,4 +1,4 @@
|
||||
FILE: companionPropertyAndTypeParameter2.fir.kt
|
||||
FILE: companionPropertyAndTypeParameter2.kt
|
||||
public final class Owner<test> : R|kotlin/Any| {
|
||||
public constructor<test>(): R|Owner<test>| {
|
||||
super<R|kotlin/Any|>()
|
||||
@@ -19,11 +19,11 @@ FILE: companionPropertyAndTypeParameter2.fir.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?|
|
||||
public get(): <ERROR TYPE REF: Type parameter test in qualified access>
|
||||
public final val some: R|kotlin/Int| = this@R|/Owner.Companion|.R|/Owner.Companion.test|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval some: <ERROR TYPE REF: Type parameter test in qualified access> = R|?|
|
||||
lval some: R|kotlin/Int| = this@R|/Owner.Companion|.R|/Owner.Companion.test|
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-58028, KT-63377
|
||||
// FIR_DUMP
|
||||
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@ class OuterClass<OuterParam> {
|
||||
class OuterParam
|
||||
|
||||
fun <NestedParam : OuterParam> foo(t: NestedParam) {
|
||||
val k: OuterParam = <!INITIALIZER_TYPE_MISMATCH!>t<!>
|
||||
val l: OuterParam = OuterParam()
|
||||
val k: OuterParam = t
|
||||
val l: OuterParam = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>OuterParam()<!>
|
||||
}
|
||||
|
||||
inner class Inner<NestedParam : OuterParam>(t: NestedParam) {
|
||||
@@ -14,8 +14,8 @@ class OuterClass<OuterParam> {
|
||||
val l: OuterParam = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>OuterParam()<!>
|
||||
|
||||
init {
|
||||
val m: OuterParam = <!INITIALIZER_TYPE_MISMATCH!>t<!>
|
||||
val n: OuterParam = OuterParam()
|
||||
val m: OuterParam = t
|
||||
val n: OuterParam = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>OuterParam()<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -12,8 +12,8 @@ FILE: memberTypeParameterVsNestedClass.fir.kt
|
||||
}
|
||||
|
||||
public final fun <NestedParam : R|OuterParam|> foo(t: R|NestedParam|): R|kotlin/Unit| {
|
||||
lval k: R|OuterClass.OuterParam| = R|<local>/t|
|
||||
lval l: R|OuterClass.OuterParam| = R|/OuterClass.OuterParam.OuterParam|()
|
||||
lval k: R|OuterParam| = R|<local>/t|
|
||||
lval l: R|OuterParam| = R|/OuterClass.OuterParam.OuterParam<CS errors: /OuterClass.OuterParam.OuterParam>#|()
|
||||
}
|
||||
|
||||
public final inner class Inner<NestedParam : R|OuterParam|, Outer(OuterParam)> : R|kotlin/Any| {
|
||||
@@ -28,8 +28,8 @@ FILE: memberTypeParameterVsNestedClass.fir.kt
|
||||
public get(): R|OuterParam|
|
||||
|
||||
init {
|
||||
lval m: R|OuterClass.OuterParam| = R|<local>/t|
|
||||
lval n: R|OuterClass.OuterParam| = R|/OuterClass.OuterParam.OuterParam|()
|
||||
lval m: R|OuterParam| = R|<local>/t|
|
||||
lval n: R|OuterParam| = R|/OuterClass.OuterParam.OuterParam<CS errors: /OuterClass.OuterParam.OuterParam>#|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -11,7 +11,7 @@ class Outer {
|
||||
}
|
||||
|
||||
fun <T> bar() {
|
||||
<!TYPE_PARAMETER_AS_REIFIED!>T::class<!>
|
||||
T::class
|
||||
val x: T? = null
|
||||
val y: T? = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>T()<!>
|
||||
}
|
||||
@@ -21,8 +21,8 @@ class Owner<T> {
|
||||
class T
|
||||
|
||||
fun baz() {
|
||||
<!TYPE_PARAMETER_AS_REIFIED!>T::class<!>
|
||||
T::class
|
||||
val x: T? = null
|
||||
val y: T? = T()
|
||||
val y: T? = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>T()<!>
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-5
@@ -12,13 +12,13 @@ FILE: memberTypeParameterVsNestedClass2.fir.kt
|
||||
}
|
||||
|
||||
public final inline fun <reified T> foo(): R|kotlin/Unit| {
|
||||
<getClass>(R|T|)
|
||||
<getClass>(Q|Outer.T|)
|
||||
lval x: R|T?| = Null(null)
|
||||
lval y: R|T?| = R|/Outer.T.T<CS errors: /Outer.T.T>#|()
|
||||
}
|
||||
|
||||
public final fun <T> bar(): R|kotlin/Unit| {
|
||||
<getClass>(R|?|)
|
||||
<getClass>(Q|Outer.T|)
|
||||
lval x: R|T?| = Null(null)
|
||||
lval y: R|T?| = R|/Outer.T.T<CS errors: /Outer.T.T>#|()
|
||||
}
|
||||
@@ -37,9 +37,9 @@ FILE: memberTypeParameterVsNestedClass2.fir.kt
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
<getClass>(R|?|)
|
||||
lval x: R|Owner.T?| = Null(null)
|
||||
lval y: R|Owner.T?| = R|/Owner.T.T|()
|
||||
<getClass>(Q|Owner.T|)
|
||||
lval x: R|T?| = Null(null)
|
||||
lval y: R|T?| = R|/Owner.T.T<CS errors: /Owner.T.T>#|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -31,23 +31,23 @@ class OuterClassWithClass<OuterParam> {
|
||||
}
|
||||
|
||||
val k = ::OuterParam
|
||||
val l = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>OuterParam::<!UNRESOLVED_REFERENCE!>foo<!><!>
|
||||
val l = OuterParam::foo
|
||||
val m = OuterParam()::foo
|
||||
|
||||
fun foo() {
|
||||
val k = ::OuterParam
|
||||
val l = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>OuterParam::<!UNRESOLVED_REFERENCE!>foo<!><!>
|
||||
val l = OuterParam::foo
|
||||
val m = OuterParam()::foo
|
||||
}
|
||||
|
||||
inner class Inner<NestedParam : OuterParam>(t: NestedParam) {
|
||||
val k = ::OuterParam
|
||||
val l = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>OuterParam::<!UNRESOLVED_REFERENCE!>foo<!><!>
|
||||
val l = OuterParam::foo
|
||||
val m = OuterParam()::foo
|
||||
|
||||
init {
|
||||
val k = ::OuterParam
|
||||
val l = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>OuterParam::<!UNRESOLVED_REFERENCE!>foo<!><!>
|
||||
val l = OuterParam::foo
|
||||
val m = OuterParam()::foo
|
||||
}
|
||||
}
|
||||
|
||||
compiler/testData/diagnostics/tests/typeParameters/memberTypeParameterVsNestedClassReference.fir.txt
Vendored
+6
-6
@@ -62,15 +62,15 @@ FILE: memberTypeParameterVsNestedClassReference.fir.kt
|
||||
public final val k: R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>| = ::R|/OuterClassWithClass.OuterParam.OuterParam|
|
||||
public get(): R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>|
|
||||
|
||||
public final val l: <ERROR TYPE REF: Unresolved reference: foo> = R|?|::<Unresolved reference: foo>#
|
||||
public get(): <ERROR TYPE REF: Unresolved reference: foo>
|
||||
public final val l: R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>| = Q|OuterClassWithClass.OuterParam|::R|/OuterClassWithClass.OuterParam.foo|
|
||||
public get(): R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>|
|
||||
|
||||
public final val m: R|kotlin/reflect/KFunction0<kotlin/Unit>| = R|/OuterClassWithClass.OuterParam.OuterParam|()::R|/OuterClassWithClass.OuterParam.foo|
|
||||
public get(): R|kotlin/reflect/KFunction0<kotlin/Unit>|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval k: R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>| = ::R|/OuterClassWithClass.OuterParam.OuterParam|
|
||||
lval l: <ERROR TYPE REF: Unresolved reference: foo> = R|?|::<Unresolved reference: foo>#
|
||||
lval l: R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>| = Q|OuterClassWithClass.OuterParam|::R|/OuterClassWithClass.OuterParam.foo|
|
||||
lval m: R|kotlin/reflect/KFunction0<kotlin/Unit>| = R|/OuterClassWithClass.OuterParam.OuterParam|()::R|/OuterClassWithClass.OuterParam.foo|
|
||||
}
|
||||
|
||||
@@ -82,15 +82,15 @@ FILE: memberTypeParameterVsNestedClassReference.fir.kt
|
||||
public final val k: R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>| = ::R|/OuterClassWithClass.OuterParam.OuterParam|
|
||||
public get(): R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>|
|
||||
|
||||
public final val l: <ERROR TYPE REF: Unresolved reference: foo> = R|?|::<Unresolved reference: foo>#
|
||||
public get(): <ERROR TYPE REF: Unresolved reference: foo>
|
||||
public final val l: R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>| = Q|OuterClassWithClass.OuterParam|::R|/OuterClassWithClass.OuterParam.foo|
|
||||
public get(): R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>|
|
||||
|
||||
public final val m: R|kotlin/reflect/KFunction0<kotlin/Unit>| = R|/OuterClassWithClass.OuterParam.OuterParam|()::R|/OuterClassWithClass.OuterParam.foo|
|
||||
public get(): R|kotlin/reflect/KFunction0<kotlin/Unit>|
|
||||
|
||||
init {
|
||||
lval k: R|kotlin/reflect/KFunction0<OuterClassWithClass.OuterParam>| = ::R|/OuterClassWithClass.OuterParam.OuterParam|
|
||||
lval l: <ERROR TYPE REF: Unresolved reference: foo> = R|?|::<Unresolved reference: foo>#
|
||||
lval l: R|kotlin/reflect/KFunction1<OuterClassWithClass.OuterParam, kotlin/Unit>| = Q|OuterClassWithClass.OuterParam|::R|/OuterClassWithClass.OuterParam.foo|
|
||||
lval m: R|kotlin/reflect/KFunction0<kotlin/Unit>| = R|/OuterClassWithClass.OuterParam.OuterParam|()::R|/OuterClassWithClass.OuterParam.foo|
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user