[FIR] Report separate error for delegated constructor call to interface

#KT-59216 Fixed
This commit is contained in:
Kirill Rakhman
2023-06-23 13:50:34 +02:00
committed by Space Team
parent 5abab2197b
commit e7c213e06e
19 changed files with 78 additions and 21 deletions
@@ -363,6 +363,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.NO_CONSTRUCTOR) { firDiagnostic ->
NoConstructorImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.FUNCTION_CALL_EXPECTED) { firDiagnostic ->
FunctionCallExpectedImpl(
firDiagnostic.a,
@@ -295,6 +295,10 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = CreatingAnInstanceOfAbstractClass::class
}
interface NoConstructor : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = NoConstructor::class
}
interface FunctionCallExpected : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = FunctionCallExpected::class
val functionName: String
@@ -339,6 +339,11 @@ internal class CreatingAnInstanceOfAbstractClassImpl(
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.CreatingAnInstanceOfAbstractClass
internal class NoConstructorImpl(
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.NoConstructor
internal class FunctionCallExpectedImpl(
override val functionName: String,
override val hasValueParameters: Boolean,
@@ -1,3 +1,3 @@
KtErrorCallInfo:
candidateCalls = []
diagnostic = ERROR<UNRESOLVED_REFERENCE: Unresolved reference: <init>>
diagnostic = ERROR<NO_CONSTRUCTOR: This type does not have a constructor.>