[FIR] Implement checks for contract not allowed
^KT-55423 Fixed
This commit is contained in:
committed by
Space Team
parent
b2fbf8bed5
commit
f946ddeb40
+7
@@ -3678,6 +3678,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.CONTRACT_NOT_ALLOWED) { firDiagnostic ->
|
||||
ContractNotAllowedImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.NO_GET_METHOD) { firDiagnostic ->
|
||||
NoGetMethodImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+5
@@ -2567,6 +2567,11 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
abstract val reason: String
|
||||
}
|
||||
|
||||
abstract class ContractNotAllowed : KtFirDiagnostic<KtElement>() {
|
||||
override val diagnosticClass get() = ContractNotAllowed::class
|
||||
abstract val reason: String
|
||||
}
|
||||
|
||||
abstract class NoGetMethod : KtFirDiagnostic<KtArrayAccessExpression>() {
|
||||
override val diagnosticClass get() = NoGetMethod::class
|
||||
}
|
||||
|
||||
+6
@@ -3096,6 +3096,12 @@ internal class ErrorInContractDescriptionImpl(
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.ErrorInContractDescription(), KtAbstractFirDiagnostic<KtElement>
|
||||
|
||||
internal class ContractNotAllowedImpl(
|
||||
override val reason: String,
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.ContractNotAllowed(), KtAbstractFirDiagnostic<KtElement>
|
||||
|
||||
internal class NoGetMethodImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ internal object FirLazyBodiesCalculator {
|
||||
|
||||
constructor.apply {
|
||||
replaceBody(newConstructor.body)
|
||||
replaceContractDescription(newConstructor.contractDescription)
|
||||
replaceDelegatedConstructor(newConstructor.delegatedConstructor)
|
||||
replaceValueParameterDefaultValues(valueParameters, newConstructor.valueParameters)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user