[FIR] Move type parameter scope above member and static scopes in tower
This fixes a false positive TYPE_PARAMETER_IS_NOT_AN_EXPRESSION when a type parameter and some member, static or companion declaration have the same name and referred to inside a class. #KT-58028 Fixed
This commit is contained in:
committed by
Space Team
parent
7958a9debd
commit
bd9f36ad01
+24
@@ -202,6 +202,21 @@ class FirTowerDataContext private constructor(
|
||||
return addNonLocalScope(scope)
|
||||
}
|
||||
|
||||
// Optimized version for two parameters
|
||||
fun addNonLocalScopesIfNotNull(scope1: FirScope?, scope2: FirScope?): FirTowerDataContext {
|
||||
return if (scope1 != null) {
|
||||
if (scope2 != null) {
|
||||
addNonLocalScopeElements(listOf(scope1.asTowerDataElement(isLocal = false), scope2.asTowerDataElement(isLocal = false)))
|
||||
} else {
|
||||
addNonLocalScope(scope1)
|
||||
}
|
||||
} else if (scope2 != null) {
|
||||
addNonLocalScope(scope2)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
fun addNonLocalScope(scope: FirScope): FirTowerDataContext {
|
||||
val element = scope.asTowerDataElement(isLocal = false)
|
||||
return FirTowerDataContext(
|
||||
@@ -212,6 +227,15 @@ class FirTowerDataContext private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun addNonLocalScopeElements(elements: List<FirTowerDataElement>): FirTowerDataContext {
|
||||
return FirTowerDataContext(
|
||||
towerDataElements.addAll(elements),
|
||||
implicitReceiverStack,
|
||||
localScopes,
|
||||
nonLocalTowerDataElements.addAll(elements)
|
||||
)
|
||||
}
|
||||
|
||||
fun createSnapshot(): FirTowerDataContext {
|
||||
return FirTowerDataContext(
|
||||
towerDataElements.map(FirTowerDataElement::createSnapshot).toPersistentList(),
|
||||
|
||||
Reference in New Issue
Block a user