FIR: introduce delegate diagnostics
This commit adds diagnostics for the following * DELEGATE_SPECIAL_FUNCTION_MISSING * DELEGATE_SPECIAL_FUNCTION_AMBIGUITY * DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
This commit is contained in:
committed by
Mikhail Glukhikh
parent
454ae3b17a
commit
b5caa658d6
+29
@@ -1862,6 +1862,35 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.DELEGATE_SPECIAL_FUNCTION_MISSING) { firDiagnostic ->
|
||||
DelegateSpecialFunctionMissingImpl(
|
||||
firDiagnostic.a,
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
|
||||
firDiagnostic.c,
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.DELEGATE_SPECIAL_FUNCTION_AMBIGUITY) { firDiagnostic ->
|
||||
DelegateSpecialFunctionAmbiguityImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic.b.map { abstractFirBasedSymbol ->
|
||||
firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration)
|
||||
},
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE) { firDiagnostic ->
|
||||
DelegateSpecialFunctionNoneApplicableImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic.b.map { abstractFirBasedSymbol ->
|
||||
firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration)
|
||||
},
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.TOPLEVEL_TYPEALIASES_ONLY) { firDiagnostic ->
|
||||
ToplevelTypealiasesOnlyImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
|
||||
+19
@@ -1305,6 +1305,25 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
abstract val candidates: List<KtSymbol>
|
||||
}
|
||||
|
||||
abstract class DelegateSpecialFunctionMissing : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = DelegateSpecialFunctionMissing::class
|
||||
abstract val expectedFunctionSignature: String
|
||||
abstract val delegateType: KtType
|
||||
abstract val description: String
|
||||
}
|
||||
|
||||
abstract class DelegateSpecialFunctionAmbiguity : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = DelegateSpecialFunctionAmbiguity::class
|
||||
abstract val expectedFunctionSignature: String
|
||||
abstract val candidates: List<KtSymbol>
|
||||
}
|
||||
|
||||
abstract class DelegateSpecialFunctionNoneApplicable : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = DelegateSpecialFunctionNoneApplicable::class
|
||||
abstract val expectedFunctionSignature: String
|
||||
abstract val candidates: List<KtSymbol>
|
||||
}
|
||||
|
||||
abstract class ToplevelTypealiasesOnly : KtFirDiagnostic<KtTypeAlias>() {
|
||||
override val diagnosticClass get() = ToplevelTypealiasesOnly::class
|
||||
}
|
||||
|
||||
+28
@@ -2116,6 +2116,34 @@ internal class NextNoneApplicableImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class DelegateSpecialFunctionMissingImpl(
|
||||
override val expectedFunctionSignature: String,
|
||||
override val delegateType: KtType,
|
||||
override val description: String,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.DelegateSpecialFunctionMissing(), KtAbstractFirDiagnostic<KtExpression> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class DelegateSpecialFunctionAmbiguityImpl(
|
||||
override val expectedFunctionSignature: String,
|
||||
override val candidates: List<KtSymbol>,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.DelegateSpecialFunctionAmbiguity(), KtAbstractFirDiagnostic<KtExpression> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class DelegateSpecialFunctionNoneApplicableImpl(
|
||||
override val expectedFunctionSignature: String,
|
||||
override val candidates: List<KtSymbol>,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.DelegateSpecialFunctionNoneApplicable(), KtAbstractFirDiagnostic<KtExpression> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class ToplevelTypealiasesOnlyImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
|
||||
Reference in New Issue
Block a user