[FIR] Properly calculate visibilities

`testIntersectionOfPrimitiveBasedFunctions`
is fine, because we deprecate this
already in ^KT-63243.

`CANNOT_INFER_VISIBILITY` is
positioned as `DECLARATION_NAME`,
just in case we decide for
some reason that we do want to
report it along with
`MANY_*_NOT_IMPLEMENTED`. In that
case, we'd get a problem that
their bounds overlap, but not
completely contain one another.

^KT-63741 Fixed
^KT-59400 Fixed
This commit is contained in:
Nikolay Lunyak
2024-01-19 12:44:09 +02:00
committed by Space Team
parent 7056ad5325
commit 8f8c7fe7cf
31 changed files with 203 additions and 139 deletions
@@ -2718,6 +2718,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.CANNOT_INFER_VISIBILITY) { firDiagnostic ->
CannotInferVisibilityImpl(
firSymbolBuilder.callableBuilder.buildCallableSymbol(firDiagnostic.a),
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES) { firDiagnostic ->
MultipleDefaultsInheritedFromSupertypesImpl(
firDiagnostic.a,
@@ -1927,6 +1927,11 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
val containingClassName: Name
}
interface CannotInferVisibility : KtFirDiagnostic<KtDeclaration> {
override val diagnosticClass get() = CannotInferVisibility::class
val callable: KtCallableSymbol
}
interface MultipleDefaultsInheritedFromSupertypes : KtFirDiagnostic<KtElement> {
override val diagnosticClass get() = MultipleDefaultsInheritedFromSupertypes::class
val name: Name
@@ -2315,6 +2315,12 @@ internal class CannotChangeAccessPrivilegeImpl(
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtModifierListOwner>(firDiagnostic, token), KtFirDiagnostic.CannotChangeAccessPrivilege
internal class CannotInferVisibilityImpl(
override val callable: KtCallableSymbol,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtDeclaration>(firDiagnostic, token), KtFirDiagnostic.CannotInferVisibility
internal class MultipleDefaultsInheritedFromSupertypesImpl(
override val name: Name,
override val valueParameter: KtSymbol,