K2: Get rid of last unhandled CheckerContext modification

Previously, it was necessary because otherwise reporting diagnostics
from a checker of FirFile level didn't work

Now, it has been fixed in the previous commit
This commit is contained in:
Denis.Zharkov
2023-02-08 11:15:54 +01:00
committed by Space Team
parent a71251d856
commit aa8885ddfc
@@ -232,48 +232,43 @@ object FirConflictsChecker : FirBasicDeclarationChecker() {
} }
} }
context.addDeclaration(declaration) inspector.declarationConflictingSymbols.forEach { (conflictingDeclaration, symbols) ->
try { val source = conflictingDeclaration.source
inspector.declarationConflictingSymbols.forEach { (conflictingDeclaration, symbols) -> if (source != null && symbols.isNotEmpty()) {
val source = conflictingDeclaration.source when (conflictingDeclaration) {
if (source != null && symbols.isNotEmpty()) { is FirSimpleFunction,
when (conflictingDeclaration) { is FirConstructor -> {
is FirSimpleFunction, reporter.reportOn(source, FirErrors.CONFLICTING_OVERLOADS, symbols, context)
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 -> { 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)
} }
} }
} }
} finally { }
context.dropDeclaration()
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 -> {
}
}
} }
} }
@@ -381,5 +376,3 @@ private fun FirRegularClass.onConstructors(action: (ctor: FirConstructor) -> Uni
acceptChildren(ClassConstructorVisitor()) acceptChildren(ClassConstructorVisitor())
} }
} }