Skip to content

Commit

Permalink
FE: Forbid overlapping underlying types of inline children
Browse files Browse the repository at this point in the history
of sealed inline class.
Implement sealed inline class related diagnostics in FIR.

 #KT-27576
  • Loading branch information
ilmirus committed Jul 19, 2022
1 parent ac7d1fe commit 91bc4fb
Show file tree
Hide file tree
Showing 49 changed files with 1,157 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.VALUE_OBJECT_NOT_SEALED_INLINE_CHILD) { firDiagnostic ->
ValueObjectNotSealedInlineChildImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.SEALED_INLINE_CHILD_NOT_VALUE) { firDiagnostic ->
SealedInlineChildNotValueImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.NONE_APPLICABLE) { firDiagnostic ->
NoneApplicableImpl(
firDiagnostic.a.map { firBasedSymbol ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,14 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = ValueClassCannotBeCloneable::class
}

abstract class ValueObjectNotSealedInlineChild : KtFirDiagnostic<KtDeclaration>() {
override val diagnosticClass get() = ValueObjectNotSealedInlineChild::class
}

abstract class SealedInlineChildNotValue : KtFirDiagnostic<KtDeclaration>() {
override val diagnosticClass get() = SealedInlineChildNotValue::class
}

abstract class NoneApplicable : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = NoneApplicable::class
abstract val candidates: List<KtSymbol>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,16 @@ internal class ValueClassCannotBeCloneableImpl(
override val token: KtLifetimeToken,
) : KtFirDiagnostic.ValueClassCannotBeCloneable(), KtAbstractFirDiagnostic<KtDeclaration>

internal class ValueObjectNotSealedInlineChildImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.ValueObjectNotSealedInlineChild(), KtAbstractFirDiagnostic<KtDeclaration>

internal class SealedInlineChildNotValueImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.SealedInlineChildNotValue(), KtAbstractFirDiagnostic<KtDeclaration>

internal class NoneApplicableImpl(
override val candidates: List<KtSymbol>,
override val firDiagnostic: KtPsiDiagnostic,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
val SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS by error<PsiElement>()
val INNER_CLASS_INSIDE_VALUE_CLASS by error<KtDeclaration>(PositioningStrategy.INNER_MODIFIER)
val VALUE_CLASS_CANNOT_BE_CLONEABLE by error<KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
val VALUE_OBJECT_NOT_SEALED_INLINE_CHILD by error<KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
val SEALED_INLINE_CHILD_NOT_VALUE by error<KtDeclaration>()
val SEALED_INLINE_CHILD_OVERLAPPING_TYPE by error<KtDeclaration>(PositioningStrategy.INLINE_OR_VALUE_MODIFIER)
}

val APPLICABILITY by object : DiagnosticGroup("Applicability") {
Expand Down
Loading

0 comments on commit 91bc4fb

Please sign in to comment.