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) -> context.addDeclaration(declaration)
val source = conflictingDeclaration.source try {
if (source != null && symbols.isNotEmpty()) { inspector.declarationConflictingSymbols.forEach { (conflictingDeclaration, symbols) ->
when (conflictingDeclaration) { val source = conflictingDeclaration.source
is FirSimpleFunction, if (source != null && symbols.isNotEmpty()) {
is FirConstructor -> { when (conflictingDeclaration) {
reporter.reportOn(source, FirErrors.CONFLICTING_OVERLOADS, symbols, context) 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 -> { 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 -> {
}
}
} }
} }