[FIR] Implement FirInterfaceDefaultMethodCallChecker

Add diagnostics: INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET,
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER,
DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET
This commit is contained in:
Ivan Kochurkin
2021-09-01 22:31:16 +03:00
committed by TeamCityServer
parent 97bc079634
commit f414a91c66
19 changed files with 325 additions and 464 deletions
@@ -361,6 +361,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirJvmErrors.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER) { firDiagnostic ->
InterfaceCantCallDefaultMethodViaSuperImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirErrors.NOT_A_SUPERTYPE) { firDiagnostic ->
NotASupertypeImpl(
firDiagnostic as FirPsiDiagnostic,
@@ -3820,4 +3826,28 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirJvmErrors.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.errorFactory) { firDiagnostic ->
DefaultMethodCallFromJava6TargetErrorImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirJvmErrors.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.warningFactory) { firDiagnostic ->
DefaultMethodCallFromJava6TargetWarningImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirJvmErrors.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.errorFactory) { firDiagnostic ->
InterfaceStaticMethodCallFromJava6TargetErrorImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirJvmErrors.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.warningFactory) { firDiagnostic ->
InterfaceStaticMethodCallFromJava6TargetWarningImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
}
@@ -281,6 +281,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val name: String
}
abstract class InterfaceCantCallDefaultMethodViaSuper : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InterfaceCantCallDefaultMethodViaSuper::class
}
abstract class NotASupertype : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = NotASupertype::class
}
@@ -2656,4 +2660,20 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = JvmSyntheticOnDelegate::class
}
abstract class DefaultMethodCallFromJava6TargetError : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = DefaultMethodCallFromJava6TargetError::class
}
abstract class DefaultMethodCallFromJava6TargetWarning : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = DefaultMethodCallFromJava6TargetWarning::class
}
abstract class InterfaceStaticMethodCallFromJava6TargetError : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InterfaceStaticMethodCallFromJava6TargetError::class
}
abstract class InterfaceStaticMethodCallFromJava6TargetWarning : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InterfaceStaticMethodCallFromJava6TargetWarning::class
}
}
@@ -417,6 +417,13 @@ internal class SuperCallWithDefaultParametersImpl(
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class InterfaceCantCallDefaultMethodViaSuperImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.InterfaceCantCallDefaultMethodViaSuper(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class NotASupertypeImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
@@ -4319,3 +4326,31 @@ internal class JvmSyntheticOnDelegateImpl(
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class DefaultMethodCallFromJava6TargetErrorImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.DefaultMethodCallFromJava6TargetError(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class DefaultMethodCallFromJava6TargetWarningImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.DefaultMethodCallFromJava6TargetWarning(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class InterfaceStaticMethodCallFromJava6TargetErrorImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.InterfaceStaticMethodCallFromJava6TargetError(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class InterfaceStaticMethodCallFromJava6TargetWarningImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.InterfaceStaticMethodCallFromJava6TargetWarning(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}