FIR: fix lookup tracking in conflicts checker for LT

since it relies on the correct context declaration
This commit is contained in:
Ilya Chernikov
2021-12-28 15:50:13 +01:00
committed by teamcity
parent 0446a21b46
commit 2689ebf455
@@ -222,43 +222,48 @@ object FirConflictsChecker : FirBasicDeclarationChecker() {
}
}
inspector.declarationConflictingSymbols.forEach { (conflictingDeclaration, symbols) ->
val source = conflictingDeclaration.source
if (source != null && symbols.isNotEmpty()) {
when (conflictingDeclaration) {
is FirSimpleFunction,
is FirConstructor -> {
reporter.reportOn(source, FirErrors.CONFLICTING_OVERLOADS, symbols, context)
context.addDeclaration(declaration)
try {
inspector.declarationConflictingSymbols.forEach { (conflictingDeclaration, symbols) ->
val source = conflictingDeclaration.source
if (source != null && symbols.isNotEmpty()) {
when (conflictingDeclaration) {
is FirSimpleFunction,
is FirConstructor -> {
reporter.reportOn(source, FirErrors.CONFLICTING_OVERLOADS, symbols, context)
}
else -> {
val factory = if (conflictingDeclaration is FirClassLikeDeclaration &&
conflictingDeclaration.getContainingDeclaration(context.session) == null &&
symbols.any { it is FirClassLikeSymbol<*> }
) {
FirErrors.PACKAGE_OR_CLASSIFIER_REDECLARATION
} else {
FirErrors.REDECLARATION
}
reporter.reportOn(source, factory, symbols, context)
}
}
}
}
if (declaration.source?.kind !is KtFakeSourceElementKind) {
when (declaration) {
is FirMemberDeclaration -> {
if (declaration is FirFunction) {
checkConflictingParameters(declaration.valueParameters, context, reporter)
}
checkConflictingParameters(declaration.typeParameters, context, reporter)
}
is FirTypeParametersOwner -> {
checkConflictingParameters(declaration.typeParameters, context, reporter)
}
else -> {
val factory = if (conflictingDeclaration is FirClassLikeDeclaration &&
conflictingDeclaration.getContainingDeclaration(context.session) == null &&
symbols.any { it is FirClassLikeSymbol<*> }
) {
FirErrors.PACKAGE_OR_CLASSIFIER_REDECLARATION
} else {
FirErrors.REDECLARATION
}
reporter.reportOn(source, factory, symbols, context)
}
}
}
}
if (declaration.source?.kind !is KtFakeSourceElementKind) {
when (declaration) {
is FirMemberDeclaration -> {
if (declaration is FirFunction) {
checkConflictingParameters(declaration.valueParameters, context, reporter)
}
checkConflictingParameters(declaration.typeParameters, context, reporter)
}
is FirTypeParametersOwner -> {
checkConflictingParameters(declaration.typeParameters, context, reporter)
}
else -> {
}
}
} finally {
context.dropDeclaration()
}
}