[FIR] Take constructors from scopes when checking conflicts
^KT-61243 Fixed
This commit is contained in:
committed by
Space Team
parent
f719436d1f
commit
942bff8a03
+12
-20
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusIm
|
|||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl.Companion.DEFAULT_STATUS_FOR_SUSPEND_MAIN_FUNCTION
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl.Companion.DEFAULT_STATUS_FOR_SUSPEND_MAIN_FUNCTION
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.modifiersRepresentation
|
import org.jetbrains.kotlin.fir.declarations.impl.modifiersRepresentation
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.nameOrSpecialName
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
import org.jetbrains.kotlin.fir.resolve.outerType
|
import org.jetbrains.kotlin.fir.resolve.outerType
|
||||||
@@ -113,21 +114,17 @@ private fun groupTopLevelByName(declarations: List<FirDeclaration>, context: Che
|
|||||||
group.properties += declaration to representation
|
group.properties += declaration to representation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is FirRegularClass -> {
|
is FirClassLikeDeclaration -> {
|
||||||
val group = groups.getOrPut(declaration.name, ::DeclarationBuckets)
|
val representation = FirRedeclarationPresenter.represent(declaration) ?: continue
|
||||||
group.classLikes += declaration to FirRedeclarationPresenter.represent(declaration)
|
val group = groups.getOrPut(declaration.nameOrSpecialName, ::DeclarationBuckets)
|
||||||
if (declaration.classKind != ClassKind.OBJECT) {
|
group.classLikes += declaration to representation
|
||||||
declaration.declarations
|
|
||||||
.filterIsInstance<FirConstructor>()
|
|
||||||
.mapTo(group.constructors) { it to FirRedeclarationPresenter.represent(it, declaration.symbol) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is FirTypeAlias -> {
|
|
||||||
val group = groups.getOrPut(declaration.name, ::DeclarationBuckets)
|
|
||||||
group.classLikes += declaration to FirRedeclarationPresenter.represent(declaration)
|
|
||||||
|
|
||||||
@OptIn(SymbolInternals::class)
|
declaration.expandedClassWithConstructorsScope(context)?.let { (expandedClass, scopeWithConstructors) ->
|
||||||
declaration.expandedClassWithConstructorsScope(context)?.let { (_, scopeWithConstructors) ->
|
if (expandedClass.classKind == ClassKind.OBJECT) {
|
||||||
|
return@let
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(SymbolInternals::class)
|
||||||
scopeWithConstructors.processDeclaredConstructors {
|
scopeWithConstructors.processDeclaredConstructors {
|
||||||
group.constructors += it.fir to FirRedeclarationPresenter.represent(it.fir, declaration.symbol)
|
group.constructors += it.fir to FirRedeclarationPresenter.represent(it.fir, declaration.symbol)
|
||||||
}
|
}
|
||||||
@@ -183,12 +180,7 @@ fun collectConflictingLocalFunctionsFrom(block: FirBlock, context: CheckerContex
|
|||||||
when (collectable) {
|
when (collectable) {
|
||||||
is FirSimpleFunction ->
|
is FirSimpleFunction ->
|
||||||
inspector.collect(collectable, FirRedeclarationPresenter.represent(collectable), functionDeclarations)
|
inspector.collect(collectable, FirRedeclarationPresenter.represent(collectable), functionDeclarations)
|
||||||
is FirRegularClass ->
|
is FirClassLikeDeclaration -> {
|
||||||
// TODO, KT-61243: Use declaredMemberScope
|
|
||||||
collectable.declarations.filterIsInstance<FirConstructor>().forEach {
|
|
||||||
inspector.collect(it, FirRedeclarationPresenter.represent(it, collectable.symbol), functionDeclarations)
|
|
||||||
}
|
|
||||||
is FirTypeAlias -> {
|
|
||||||
collectable.expandedClassWithConstructorsScope(context)?.let { (_, scopeWithConstructors) ->
|
collectable.expandedClassWithConstructorsScope(context)?.let { (_, scopeWithConstructors) ->
|
||||||
scopeWithConstructors.processDeclaredConstructors {
|
scopeWithConstructors.processDeclaredConstructors {
|
||||||
@OptIn(SymbolInternals::class)
|
@OptIn(SymbolInternals::class)
|
||||||
|
|||||||
Reference in New Issue
Block a user