K2: don't use outer class type parameters during nested class TP resolve

Before this commit, we allowed access to outer class type parameters
during resolve of type parameter bounds of a nested class.
In fact, outer type parameters are accessible in this situation
only if it's an inner class (or a local class).
This commit forbids such a usage. In the earlier fix of KT-57209
the same was done for regular type reference resolve.

#KT-61459 Fixed
#KT-61959 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-09-08 17:08:56 +02:00
committed by Space Team
parent cdc197c723
commit 9cf1d36e5e
7 changed files with 10 additions and 40 deletions
@@ -1,6 +1,5 @@
package test
class Outer<MyParam> {
// TODO this test has an error, MyParam should not be resolved here. See KT-61959
class Nested<T : <expr>MyParam</expr>>
}
@@ -20,7 +20,7 @@ Tower Data Context:
Element 8
Scope: FirNestedClassifierScopeImpl
Classifiers:
FirRegularClassSymbol public final class Nested<T : R|MyParam|> : R|kotlin/Any|
FirRegularClassSymbol public final class Nested<T : <ERROR TYPE REF: Symbol not found for MyParam>> : R|kotlin/Any|
Element 9
Implicit receiver:
FirRegularClassSymbol public final class Outer<MyParam> : R|kotlin/Any|
@@ -28,7 +28,7 @@ Tower Data Context:
Element 10
Scope: FirMemberTypeParameterScope
Classifiers:
FirTypeParameterSymbol T : R|MyParam|
FirTypeParameterSymbol T : <ERROR TYPE REF: Symbol not found for MyParam>
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeBound.kt
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
@@ -36,8 +36,8 @@ FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeBound.kt
super<R|kotlin/Any|>()
}
public final [ResolvedTo(STATUS)] class Nested<[ResolvedTo(STATUS)] T : R|MyParam|> : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] T : R|MyParam|>(): R|test/Outer.Nested<T>| {
public final [ResolvedTo(STATUS)] class Nested<[ResolvedTo(STATUS)] T : <ERROR TYPE REF: Symbol not found for MyParam>> : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] T : <ERROR TYPE REF: Symbol not found for MyParam>>(): R|test/Outer.Nested<T>| {
super<R|kotlin/Any|>()
}