[Wasm] Port external declaration checker to K2 (KT-56849)
Share common code with FirJsExternalChecker using FirWebCommonExternalChecker
This commit is contained in:
committed by
Space Team
parent
83aa014d81
commit
62ebb9932f
+3
-1
@@ -11,6 +11,7 @@ import java.nio.file.Paths
|
||||
import org.jetbrains.kotlin.analysis.api.fir.generator.DiagnosticClassGenerator.generate
|
||||
import org.jetbrains.kotlin.fir.builder.SYNTAX_DIAGNOSTIC_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JS_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.WEB_COMMON_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
|
||||
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||
import java.io.File
|
||||
@@ -31,6 +32,7 @@ internal fun SmartPrinter.printGeneratedMessage() {
|
||||
fun main() {
|
||||
val rootPath = Paths.get("analysis/analysis-api-fir/src").toAbsolutePath()
|
||||
val packageName = "org.jetbrains.kotlin.analysis.api.fir.diagnostics"
|
||||
val diagnostics = DIAGNOSTICS_LIST + JVM_DIAGNOSTICS_LIST + JS_DIAGNOSTICS_LIST + SYNTAX_DIAGNOSTIC_LIST
|
||||
val diagnostics = DIAGNOSTICS_LIST + JVM_DIAGNOSTICS_LIST + JS_DIAGNOSTICS_LIST + SYNTAX_DIAGNOSTIC_LIST +
|
||||
WEB_COMMON_DIAGNOSTICS_LIST
|
||||
generate(rootPath, diagnostics, packageName)
|
||||
}
|
||||
|
||||
+1
@@ -72,6 +72,7 @@ object FirDiagnosticToKtDiagnosticConverterRenderer : AbstractDiagnosticsDataCla
|
||||
"org.jetbrains.kotlin.fir.builder.FirSyntaxErrors",
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors",
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors",
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors",
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors",
|
||||
)
|
||||
}
|
||||
|
||||
+74
-73
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors
|
||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
@@ -5500,85 +5501,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER) { firDiagnostic ->
|
||||
ExternalClassConstructorPropertyParameterImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_ENUM_ENTRY_WITH_BODY) { firDiagnostic ->
|
||||
ExternalEnumEntryWithBodyImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_ANONYMOUS_INITIALIZER) { firDiagnostic ->
|
||||
ExternalAnonymousInitializerImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_DELEGATION) { firDiagnostic ->
|
||||
ExternalDelegationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL) { firDiagnostic ->
|
||||
ExternalDelegatedConstructorCallImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongBodyOfExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongInitializerOfExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER) { firDiagnostic ->
|
||||
WrongDefaultValueForExternalFunParameterImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.NESTED_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
NestedExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.WRONG_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongExternalDeclarationImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE) { firDiagnostic ->
|
||||
NestedClassInExternalInterfaceImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE) { firDiagnostic ->
|
||||
ExternalTypeExtendsNonExternalTypeImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.INLINE_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
InlineExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING) { firDiagnostic ->
|
||||
EnumClassInExternalDeclarationWarningImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
@@ -5603,12 +5537,6 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE) { firDiagnostic ->
|
||||
NonAbstractMemberOfExternalInterfaceImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJsErrors.NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE) { firDiagnostic ->
|
||||
NonExternalDeclarationInInappropriateFileImpl(
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||
@@ -5725,4 +5653,77 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.NESTED_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
NestedExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongExternalDeclarationImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE) { firDiagnostic ->
|
||||
NestedClassInExternalInterfaceImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.INLINE_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
InlineExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE) { firDiagnostic ->
|
||||
NonAbstractMemberOfExternalInterfaceImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER) { firDiagnostic ->
|
||||
ExternalClassConstructorPropertyParameterImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.EXTERNAL_ANONYMOUS_INITIALIZER) { firDiagnostic ->
|
||||
ExternalAnonymousInitializerImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.EXTERNAL_DELEGATION) { firDiagnostic ->
|
||||
ExternalDelegationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL) { firDiagnostic ->
|
||||
ExternalDelegatedConstructorCallImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongBodyOfExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION) { firDiagnostic ->
|
||||
WrongInitializerOfExternalDeclarationImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirWebCommonErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER) { firDiagnostic ->
|
||||
WrongDefaultValueForExternalFunParameterImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+49
-49
@@ -3826,59 +3826,14 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = CallToDefinedExternallyFromNonExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface ExternalClassConstructorPropertyParameter : KtFirDiagnostic<KtParameter> {
|
||||
override val diagnosticClass get() = ExternalClassConstructorPropertyParameter::class
|
||||
}
|
||||
|
||||
interface ExternalEnumEntryWithBody : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalEnumEntryWithBody::class
|
||||
}
|
||||
|
||||
interface ExternalAnonymousInitializer : KtFirDiagnostic<KtAnonymousInitializer> {
|
||||
override val diagnosticClass get() = ExternalAnonymousInitializer::class
|
||||
}
|
||||
|
||||
interface ExternalDelegation : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalDelegation::class
|
||||
}
|
||||
|
||||
interface ExternalDelegatedConstructorCall : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalDelegatedConstructorCall::class
|
||||
}
|
||||
|
||||
interface WrongBodyOfExternalDeclaration : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongBodyOfExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongInitializerOfExternalDeclaration : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongInitializerOfExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongDefaultValueForExternalFunParameter : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongDefaultValueForExternalFunParameter::class
|
||||
}
|
||||
|
||||
interface NestedExternalDeclaration : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NestedExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongExternalDeclaration : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = WrongExternalDeclaration::class
|
||||
val classKind: String
|
||||
}
|
||||
|
||||
interface NestedClassInExternalInterface : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NestedClassInExternalInterface::class
|
||||
}
|
||||
|
||||
interface ExternalTypeExtendsNonExternalType : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalTypeExtendsNonExternalType::class
|
||||
}
|
||||
|
||||
interface InlineExternalDeclaration : KtFirDiagnostic<KtDeclaration> {
|
||||
override val diagnosticClass get() = InlineExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface EnumClassInExternalDeclarationWarning : KtFirDiagnostic<KtDeclaration> {
|
||||
override val diagnosticClass get() = EnumClassInExternalDeclarationWarning::class
|
||||
}
|
||||
@@ -3895,10 +3850,6 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = ExtensionFunctionInExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface NonAbstractMemberOfExternalInterface : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NonAbstractMemberOfExternalInterface::class
|
||||
}
|
||||
|
||||
interface NonExternalDeclarationInInappropriateFile : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = NonExternalDeclarationInInappropriateFile::class
|
||||
val type: KtType
|
||||
@@ -3981,4 +3932,53 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
val message: String
|
||||
}
|
||||
|
||||
interface NestedExternalDeclaration : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NestedExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongExternalDeclaration : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = WrongExternalDeclaration::class
|
||||
val classKind: String
|
||||
}
|
||||
|
||||
interface NestedClassInExternalInterface : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NestedClassInExternalInterface::class
|
||||
}
|
||||
|
||||
interface InlineExternalDeclaration : KtFirDiagnostic<KtDeclaration> {
|
||||
override val diagnosticClass get() = InlineExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface NonAbstractMemberOfExternalInterface : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = NonAbstractMemberOfExternalInterface::class
|
||||
}
|
||||
|
||||
interface ExternalClassConstructorPropertyParameter : KtFirDiagnostic<KtParameter> {
|
||||
override val diagnosticClass get() = ExternalClassConstructorPropertyParameter::class
|
||||
}
|
||||
|
||||
interface ExternalAnonymousInitializer : KtFirDiagnostic<KtAnonymousInitializer> {
|
||||
override val diagnosticClass get() = ExternalAnonymousInitializer::class
|
||||
}
|
||||
|
||||
interface ExternalDelegation : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalDelegation::class
|
||||
}
|
||||
|
||||
interface ExternalDelegatedConstructorCall : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = ExternalDelegatedConstructorCall::class
|
||||
}
|
||||
|
||||
interface WrongBodyOfExternalDeclaration : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongBodyOfExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongInitializerOfExternalDeclaration : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongInitializerOfExternalDeclaration::class
|
||||
}
|
||||
|
||||
interface WrongDefaultValueForExternalFunParameter : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = WrongDefaultValueForExternalFunParameter::class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+61
-61
@@ -4620,72 +4620,16 @@ internal class CallToDefinedExternallyFromNonExternalDeclarationImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.CallToDefinedExternallyFromNonExternalDeclaration
|
||||
|
||||
internal class ExternalClassConstructorPropertyParameterImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtParameter>(firDiagnostic, token), KtFirDiagnostic.ExternalClassConstructorPropertyParameter
|
||||
|
||||
internal class ExternalEnumEntryWithBodyImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalEnumEntryWithBody
|
||||
|
||||
internal class ExternalAnonymousInitializerImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtAnonymousInitializer>(firDiagnostic, token), KtFirDiagnostic.ExternalAnonymousInitializer
|
||||
|
||||
internal class ExternalDelegationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalDelegation
|
||||
|
||||
internal class ExternalDelegatedConstructorCallImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalDelegatedConstructorCall
|
||||
|
||||
internal class WrongBodyOfExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongBodyOfExternalDeclaration
|
||||
|
||||
internal class WrongInitializerOfExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongInitializerOfExternalDeclaration
|
||||
|
||||
internal class WrongDefaultValueForExternalFunParameterImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongDefaultValueForExternalFunParameter
|
||||
|
||||
internal class NestedExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NestedExternalDeclaration
|
||||
|
||||
internal class WrongExternalDeclarationImpl(
|
||||
override val classKind: String,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.WrongExternalDeclaration
|
||||
|
||||
internal class NestedClassInExternalInterfaceImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NestedClassInExternalInterface
|
||||
|
||||
internal class ExternalTypeExtendsNonExternalTypeImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalTypeExtendsNonExternalType
|
||||
|
||||
internal class InlineExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtDeclaration>(firDiagnostic, token), KtFirDiagnostic.InlineExternalDeclaration
|
||||
|
||||
internal class EnumClassInExternalDeclarationWarningImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
@@ -4706,11 +4650,6 @@ internal class ExtensionFunctionInExternalDeclarationImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExtensionFunctionInExternalDeclaration
|
||||
|
||||
internal class NonAbstractMemberOfExternalInterfaceImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NonAbstractMemberOfExternalInterface
|
||||
|
||||
internal class NonExternalDeclarationInInappropriateFileImpl(
|
||||
override val type: KtType,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
@@ -4810,3 +4749,64 @@ internal class SyntaxImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.Syntax
|
||||
|
||||
internal class NestedExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NestedExternalDeclaration
|
||||
|
||||
internal class WrongExternalDeclarationImpl(
|
||||
override val classKind: String,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.WrongExternalDeclaration
|
||||
|
||||
internal class NestedClassInExternalInterfaceImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NestedClassInExternalInterface
|
||||
|
||||
internal class InlineExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtDeclaration>(firDiagnostic, token), KtFirDiagnostic.InlineExternalDeclaration
|
||||
|
||||
internal class NonAbstractMemberOfExternalInterfaceImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.NonAbstractMemberOfExternalInterface
|
||||
|
||||
internal class ExternalClassConstructorPropertyParameterImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtParameter>(firDiagnostic, token), KtFirDiagnostic.ExternalClassConstructorPropertyParameter
|
||||
|
||||
internal class ExternalAnonymousInitializerImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtAnonymousInitializer>(firDiagnostic, token), KtFirDiagnostic.ExternalAnonymousInitializer
|
||||
|
||||
internal class ExternalDelegationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalDelegation
|
||||
|
||||
internal class ExternalDelegatedConstructorCallImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.ExternalDelegatedConstructorCall
|
||||
|
||||
internal class WrongBodyOfExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongBodyOfExternalDeclaration
|
||||
|
||||
internal class WrongInitializerOfExternalDeclarationImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongInitializerOfExternalDeclaration
|
||||
|
||||
internal class WrongDefaultValueForExternalFunParameterImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.WrongDefaultValueForExternalFunParameter
|
||||
|
||||
|
||||
+3
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JS_DIAGNOSTICS_LI
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JVM_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.NATIVE_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.WASM_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.WEB_COMMON_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.ErrorListDiagnosticListRenderer
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.generateDiagnostics
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
@@ -103,6 +104,7 @@ fun main(args: Array<String>) {
|
||||
val jsGenerationPath = File(arguments.getOrElse(2) { "compiler/fir/checkers/checkers.js/gen" })
|
||||
val nativeGenerationPath = File(arguments.getOrElse(3) { "compiler/fir/checkers/checkers.native/gen" })
|
||||
val wasmGenerationPath = File(arguments.getOrElse(4) { "compiler/fir/checkers/checkers.wasm/gen" })
|
||||
val webCommonGenerationPath = File(arguments.getOrElse(5) { "compiler/fir/checkers/checkers.web.common/gen" })
|
||||
val rawFirGenerationPath = File("compiler/fir/raw-fir/raw-fir.common/gen")
|
||||
|
||||
val packageName = "$basePackage.diagnostics"
|
||||
@@ -112,6 +114,7 @@ fun main(args: Array<String>) {
|
||||
generateDiagnostics(jsGenerationPath, "$packageName.js", JS_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(nativeGenerationPath, "$packageName.native", NATIVE_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(wasmGenerationPath, "$packageName.wasm", WASM_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(webCommonGenerationPath, "$packageName.web.common", WEB_COMMON_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(rawFirGenerationPath, "org.jetbrains.kotlin.fir.builder", SYNTAX_DIAGNOSTIC_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
|
||||
generateNonSuppressibleErrorNamesFile(generationPath, packageName)
|
||||
|
||||
+2
-5
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.checkers.generator
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.fir.builder.SYNTAX_DIAGNOSTIC_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JS_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JVM_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.NATIVE_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.RegularDiagnosticData
|
||||
import org.jetbrains.kotlin.fir.tree.generator.util.writeToFileUsingSmartPrinterIfFileContentChanged
|
||||
import java.io.File
|
||||
@@ -25,7 +22,7 @@ fun generateNonSuppressibleErrorNamesFile(generationPath: File, packageName: Str
|
||||
println("val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(")
|
||||
|
||||
val combinedDiagnostics =
|
||||
DIAGNOSTICS_LIST + JVM_DIAGNOSTICS_LIST + JS_DIAGNOSTICS_LIST + NATIVE_DIAGNOSTICS_LIST + SYNTAX_DIAGNOSTIC_LIST
|
||||
DIAGNOSTICS_LIST + JVM_DIAGNOSTICS_LIST + JS_DIAGNOSTICS_LIST + NATIVE_DIAGNOSTICS_LIST + WEB_COMMON_DIAGNOSTICS_LIST + SYNTAX_DIAGNOSTIC_LIST
|
||||
for (diagnostic in combinedDiagnostics.allDiagnostics) {
|
||||
if (diagnostic is RegularDiagnosticData && diagnostic.severity == Severity.ERROR && !diagnostic.isSuppressible) {
|
||||
println(" \"${diagnostic.name}\",")
|
||||
|
||||
-14
@@ -85,26 +85,12 @@ object JS_DIAGNOSTICS_LIST : DiagnosticList("FirJsErrors") {
|
||||
parameter<FirNamedFunctionSymbol>("function")
|
||||
}
|
||||
val CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION by error<PsiElement>()
|
||||
val EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER by error<KtParameter>()
|
||||
val EXTERNAL_ENUM_ENTRY_WITH_BODY by error<KtElement>()
|
||||
val EXTERNAL_ANONYMOUS_INITIALIZER by error<KtAnonymousInitializer>()
|
||||
val EXTERNAL_DELEGATION by error<KtElement>()
|
||||
val EXTERNAL_DELEGATED_CONSTRUCTOR_CALL by error<KtElement>()
|
||||
val WRONG_BODY_OF_EXTERNAL_DECLARATION by error<KtElement>()
|
||||
val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error<KtElement>()
|
||||
val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error<KtElement>()
|
||||
val NESTED_EXTERNAL_DECLARATION by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val WRONG_EXTERNAL_DECLARATION by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
|
||||
parameter<String>("classKind")
|
||||
}
|
||||
val NESTED_CLASS_IN_EXTERNAL_INTERFACE by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_EXTERNAL_DECLARATION by error<KtDeclaration>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING by warning<KtDeclaration>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING by warning<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_CLASS_IN_EXTERNAL_DECLARATION by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
|
||||
parameter<ConeKotlinType>("type")
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.PositioningStrategy
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
|
||||
@Suppress("ClassName", "unused")
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.checkers.generator.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.PositioningStrategy
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
|
||||
@Suppress("ClassName", "unused")
|
||||
@OptIn(PrivateForInline::class)
|
||||
object WEB_COMMON_DIAGNOSTICS_LIST : DiagnosticList("FirWebCommonErrors") {
|
||||
val EXTERNALS by object : DiagnosticGroup("Externals") {
|
||||
val NESTED_EXTERNAL_DECLARATION by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val WRONG_EXTERNAL_DECLARATION by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
|
||||
parameter<String>("classKind")
|
||||
}
|
||||
val NESTED_CLASS_IN_EXTERNAL_INTERFACE by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_EXTERNAL_DECLARATION by error<KtDeclaration>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE by error<KtExpression>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER by error<KtParameter>()
|
||||
val EXTERNAL_ANONYMOUS_INITIALIZER by error<KtAnonymousInitializer>()
|
||||
val EXTERNAL_DELEGATION by error<KtElement>()
|
||||
val EXTERNAL_DELEGATED_CONSTRUCTOR_CALL by error<KtElement>()
|
||||
val WRONG_BODY_OF_EXTERNAL_DECLARATION by error<KtElement>()
|
||||
val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error<KtElement>()
|
||||
val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error<KtElement>()
|
||||
}
|
||||
}
|
||||
-14
@@ -15,12 +15,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.psi.KtAnonymousInitializer
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.fir.checkers.generator.diagnostics.JS_DIAGNOSTICS_LIST]
|
||||
@@ -63,24 +61,12 @@ object FirJsErrors {
|
||||
val OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS by error0<KtElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS_WITH_FAKE by error1<KtElement, FirNamedFunctionSymbol>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION by error0<PsiElement>()
|
||||
val EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER by error0<KtParameter>()
|
||||
val EXTERNAL_ENUM_ENTRY_WITH_BODY by error0<KtElement>()
|
||||
val EXTERNAL_ANONYMOUS_INITIALIZER by error0<KtAnonymousInitializer>()
|
||||
val EXTERNAL_DELEGATION by error0<KtElement>()
|
||||
val EXTERNAL_DELEGATED_CONSTRUCTOR_CALL by error0<KtElement>()
|
||||
val WRONG_BODY_OF_EXTERNAL_DECLARATION by error0<KtElement>()
|
||||
val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error0<KtElement>()
|
||||
val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error0<KtElement>()
|
||||
val NESTED_EXTERNAL_DECLARATION by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val WRONG_EXTERNAL_DECLARATION by error1<KtExpression, String>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NESTED_CLASS_IN_EXTERNAL_INTERFACE by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE by error0<KtElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_EXTERNAL_DECLARATION by error0<KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING by warning0<KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING by warning0<KtElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_CLASS_IN_EXTERNAL_DECLARATION by error0<KtElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION by error0<KtElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE by error1<KtElement, ConeKotlinType>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val CANNOT_CHECK_FOR_EXTERNAL_INTERFACE by error1<KtElement, ConeKotlinType>()
|
||||
val UNCHECKED_CAST_TO_EXTERNAL_INTERFACE by warning2<KtElement, ConeKotlinType, ConeKotlinType>()
|
||||
|
||||
+9
-42
@@ -15,30 +15,23 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CALL_TO_DEFI
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CANNOT_CHECK_FOR_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_ANONYMOUS_INITIALIZER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_DELEGATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_ENUM_ENTRY_WITH_BODY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.DELEGATION_BY_DYNAMIC
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.PROPERTY_DELEGATION_BY_DYNAMIC
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_ENUM_ENTRY_WITH_BODY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_INTERFACE_AS_CLASS_LITERAL
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.IMPLEMENTING_FUNCTION_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.INLINE_CLASS_IN_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_EXTERNAL_INHERITORS_ONLY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.INLINE_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JSCODE_ARGUMENT_NON_CONST_EXPRESSION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_BUILTIN_NAME_CLASH
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_EXTERNAL_ARGUMENT
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_EXTERNAL_INHERITORS_ONLY
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_FAKE_NAME_CLASH
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_MODULE_PROHIBITED_ON_NON_NATIVE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_MODULE_PROHIBITED_ON_VAR
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_JS_MODULE_PROHIBITED
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_FAKE_NAME_CLASH
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_NAME_CLASH
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_NAME_IS_NOT_ON_ALL_ACCESSORS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_NAME_ON_ACCESSOR_AND_PROPERTY
|
||||
@@ -53,24 +46,19 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEX
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEXER_WRONG_PARAMETER_COUNT
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_SETTER_WRONG_RETURN_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_JS_EXPORT
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_JS_MODULE_PROHIBITED
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NON_CONSUMABLE_EXPORTED_IDENTIFIER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NON_EXPORTABLE_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS_WITH_FAKE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.PROPERTY_DELEGATION_BY_DYNAMIC
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.RUNTIME_ANNOTATION_NOT_SUPPORTED
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.SPREAD_OPERATOR_IN_DYNAMIC_CALL
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.UNCHECKED_CAST_TO_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_EXPORTED_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_JS_QUALIFIER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_MULTIPLE_INHERITANCE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.WRONG_OPERATION_WITH_DYNAMIC
|
||||
@@ -119,25 +107,8 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
RUNTIME_ANNOTATION_NOT_SUPPORTED,
|
||||
"Reflection is not supported in JavaScript target; therefore, you won't be able to read this annotation at runtime."
|
||||
)
|
||||
map.put(EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, "External class constructor cannot have a property parameter.")
|
||||
map.put(EXTERNAL_ENUM_ENTRY_WITH_BODY, "Entry of external enum class cannot have a body.")
|
||||
map.put(EXTERNAL_ANONYMOUS_INITIALIZER, "Anonymous initializers in external classes are prohibited.")
|
||||
map.put(EXTERNAL_DELEGATION, "Cannot use delegate on external declaration.")
|
||||
map.put(EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, "Delegated constructor call in external class is prohibited.")
|
||||
map.put(
|
||||
WRONG_BODY_OF_EXTERNAL_DECLARATION,
|
||||
"Wrong body of external declaration. Must be either ' = definedExternally' or '{ definedExternally }'."
|
||||
)
|
||||
map.put(WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION, "Wrong initializer of external declaration. Must be ' = definedExternally'.")
|
||||
map.put(
|
||||
WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER,
|
||||
"Wrong default value for parameter of external function. Must be ' = definedExternally'."
|
||||
)
|
||||
map.put(NESTED_EXTERNAL_DECLARATION, "Non-top-level 'external' declaration.")
|
||||
map.put(WRONG_EXTERNAL_DECLARATION, "Declaration of such kind ({0}) cannot be external.", CommonRenderers.STRING)
|
||||
map.put(NESTED_CLASS_IN_EXTERNAL_INTERFACE, "Interface cannot contain nested classes and objects.")
|
||||
map.put(EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE, "External type extends non-external type.")
|
||||
map.put(INLINE_EXTERNAL_DECLARATION, "Inline external declaration.")
|
||||
map.put(
|
||||
INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING,
|
||||
"Using value classes as parameter type or return type of external declarations is experimental."
|
||||
@@ -151,10 +122,6 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
"Using value classes as parameter type or return type of external declarations is not supported."
|
||||
)
|
||||
map.put(EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION, "Function types with receivers are prohibited in external declarations.")
|
||||
map.put(
|
||||
NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE,
|
||||
"Only nullable properties of external interfaces are allowed to be non-abstract."
|
||||
)
|
||||
map.put(
|
||||
NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN,
|
||||
"Annotation ''{0}'' is only allowed on member functions of declarations annotated with ''kotlin.js.native'' or on top-level extension functions.",
|
||||
|
||||
+25
-221
@@ -9,97 +9,39 @@ import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactory0
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.*
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.js.checkers.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyBackingField
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.analysis.js.checkers.isNativeObject
|
||||
import org.jetbrains.kotlin.fir.analysis.js.checkers.superClassNotAny
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.analysis.web.common.FirWebCommonExternalChecker
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.JsStandardClassIds
|
||||
import org.jetbrains.kotlin.name.JsStandardClassIds.Annotations.JsNative
|
||||
import org.jetbrains.kotlin.name.WasmStandardClassIds
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
object FirJsExternalChecker : FirBasicDeclarationChecker() {
|
||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (!declaration.symbol.isNativeObject(context)) return
|
||||
object FirJsExternalChecker : FirWebCommonExternalChecker() {
|
||||
override fun isNativeOrEffectivelyExternal(symbol: FirBasedSymbol<*>, session: FirSession): Boolean {
|
||||
return symbol.isNativeObject(session)
|
||||
}
|
||||
|
||||
if (!context.isTopLevel) {
|
||||
if (declaration !is FirPropertyAccessor && declaration.isDirectlyExternal(context.session)) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.NESTED_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is FirClass) {
|
||||
// TODO: KT-55600: Stop generating diagnostic
|
||||
// messages inside checkers
|
||||
val classKind = when {
|
||||
declaration.status.isData -> "data class"
|
||||
declaration.status.isInner -> "inner class"
|
||||
declaration.status.isInline -> "value class"
|
||||
declaration.status.isFun -> "fun interface"
|
||||
declaration.classKind == ClassKind.ANNOTATION_CLASS -> "annotation class"
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (classKind != null) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.WRONG_EXTERNAL_DECLARATION, classKind, context)
|
||||
}
|
||||
|
||||
if (declaration.isEnumClass) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING, context)
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is FirPropertyAccessor && declaration.isDirectlyExternal(context.session)) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.WRONG_EXTERNAL_DECLARATION, "property accessor", context)
|
||||
} else if (
|
||||
declaration !is FirPrimaryConstructor &&
|
||||
declaration !is FirField &&
|
||||
declaration.isPrivateMemberOfExternalClass(context.session)
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.WRONG_EXTERNAL_DECLARATION, "private member of class", context)
|
||||
}
|
||||
|
||||
val container = context.containingDeclarations.lastOrNull()
|
||||
|
||||
if (
|
||||
declaration is FirClass &&
|
||||
declaration.classKind != ClassKind.INTERFACE &&
|
||||
container is FirClass && container.classKind == ClassKind.INTERFACE
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE, context)
|
||||
}
|
||||
|
||||
if (declaration !is FirPropertyAccessor && declaration is FirCallableDeclaration && declaration.isExtension) {
|
||||
val target = when (declaration) {
|
||||
is FirFunction -> "extension function"
|
||||
is FirProperty -> "extension property"
|
||||
else -> "extension member"
|
||||
}
|
||||
reporter.reportOn(declaration.source, FirJsErrors.WRONG_EXTERNAL_DECLARATION, target, context)
|
||||
}
|
||||
override fun reportExternalEnum(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING, context)
|
||||
}
|
||||
|
||||
override fun additionalCheck(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (declaration is FirClass && declaration.classKind != ClassKind.ANNOTATION_CLASS) {
|
||||
val superClasses = declaration.superInterfaces(context.session).toMutableList()
|
||||
declaration.superClassNotAny(context.session)?.let {
|
||||
@@ -115,7 +57,7 @@ object FirJsExternalChecker : FirBasicDeclarationChecker() {
|
||||
}
|
||||
|
||||
if (declaration is FirFunction && declaration.isInline) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.INLINE_EXTERNAL_DECLARATION, context)
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.INLINE_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
|
||||
fun reportOnParametersAndReturnTypesIf(
|
||||
@@ -180,20 +122,16 @@ object FirJsExternalChecker : FirBasicDeclarationChecker() {
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
declaration is FirCallableDeclaration &&
|
||||
declaration.isNonAbstractMemberIfInterface(context.session) &&
|
||||
!declaration.isNullableProperty()
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirJsErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE, context)
|
||||
}
|
||||
|
||||
declaration.checkBody(context, reporter)
|
||||
declaration.checkDelegation(context, reporter)
|
||||
declaration.checkAnonymousInitializer(context, reporter)
|
||||
declaration.checkEnumEntry(context, reporter)
|
||||
declaration.checkConstructorPropertyParam(context, reporter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isDefinedExternallyCallableId(callableId: CallableId): Boolean {
|
||||
return callableId in JsStandardClassIds.Callables.definedExternallyPropertyNames
|
||||
}
|
||||
|
||||
override fun hasExternalLikeAnnotations(declaration: FirDeclaration, session: FirSession): Boolean {
|
||||
return declaration.hasAnnotation(JsNative, session)
|
||||
}
|
||||
|
||||
private val KtSourceElement.allowsReporting
|
||||
get() = kind !is KtFakeSourceElementKind || kind == KtFakeSourceElementKind.PropertyFromParameter
|
||||
@@ -208,146 +146,12 @@ object FirJsExternalChecker : FirBasicDeclarationChecker() {
|
||||
.filterNot { it.isAny || it.isNullableAny }
|
||||
.filter { it.toSymbol(session)?.classKind == ClassKind.INTERFACE }
|
||||
|
||||
private fun FirDeclaration.checkBody(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this is FirDefaultPropertyAccessor) return
|
||||
|
||||
val body = when (this) {
|
||||
is FirFunction -> body
|
||||
is FirAnonymousInitializer -> body
|
||||
else -> null
|
||||
}
|
||||
|
||||
val initializer = when {
|
||||
this is FirEnumEntry -> null
|
||||
source?.kind == KtFakeSourceElementKind.PropertyFromParameter -> null
|
||||
this is FirVariable -> initializer
|
||||
body is FirSingleExpressionBlock -> (body.statement as? FirReturnExpression)?.result
|
||||
else -> null
|
||||
}
|
||||
|
||||
// we shouldn't check such things as the
|
||||
// copy() function of a data class
|
||||
if (source?.kind !is KtRealSourceElementKind) {
|
||||
return
|
||||
}
|
||||
|
||||
val isWrong = body !is FirSingleExpressionBlock && !hasValidExternalBody()
|
||||
|| initializer != null && !initializer.isDefinedExternallyExpression()
|
||||
|
||||
if (isWrong && body != null) {
|
||||
reporter.reportOn(body.source, FirJsErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION, context)
|
||||
} else if (isWrong && initializer != null) {
|
||||
reporter.reportOn(initializer.source, FirJsErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
|
||||
if (this is FirFunction) {
|
||||
for (defaultValue in valueParameters.mapNotNull { it.defaultValue }) {
|
||||
if (!defaultValue.isDefinedExternallyExpression()) {
|
||||
reporter.reportOn(defaultValue.source, FirJsErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkDelegation(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirMemberDeclaration || !symbol.isEffectivelyExternal(context)) return
|
||||
|
||||
if (this is FirClass) {
|
||||
declarations.firstIsInstanceOrNull<FirPrimaryConstructor>()?.let {
|
||||
val constructorCall = it.delegatedConstructor
|
||||
|
||||
if (constructorCall?.source?.kind is KtRealSourceElementKind) {
|
||||
reporter.reportOn(constructorCall.source, FirJsErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, context)
|
||||
}
|
||||
}
|
||||
|
||||
for ((superType, delegate) in collectSupertypesWithDelegates()) {
|
||||
when {
|
||||
delegate != null -> {
|
||||
reporter.reportOn(superType.source, FirJsErrors.EXTERNAL_DELEGATION, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this is FirConstructor && !isPrimary) {
|
||||
val delegationCall = delegatedConstructor
|
||||
|
||||
if (delegationCall?.source?.kind is KtRealSourceElementKind) {
|
||||
reporter.reportOn(delegationCall.source, FirJsErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, context)
|
||||
}
|
||||
} else if (this is FirProperty) {
|
||||
delegate?.let {
|
||||
reporter.reportOn(it.source, FirJsErrors.EXTERNAL_DELEGATION, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkAnonymousInitializer(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirClass) return
|
||||
|
||||
for (anonymousInitializer in anonymousInitializers) {
|
||||
reporter.reportOn(anonymousInitializer.source, FirJsErrors.EXTERNAL_ANONYMOUS_INITIALIZER, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkEnumEntry(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirEnumEntry) return
|
||||
initializer?.let {
|
||||
reporter.reportOn(it.source, FirJsErrors.EXTERNAL_ENUM_ENTRY_WITH_BODY, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkConstructorPropertyParam(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirProperty || source?.kind != KtFakeSourceElementKind.PropertyFromParameter) return
|
||||
val containingClass = getContainingClassSymbol(context.session) as? FirClassSymbol<*> ?: return
|
||||
if (containingClass.isData || containingClass.classKind == ClassKind.ANNOTATION_CLASS) return
|
||||
reporter.reportOn(source, FirJsErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, context)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isDirectlyExternal(session: FirSession): Boolean {
|
||||
// source kind is checked, otherwise this function
|
||||
// may return true for a primary constructor of an external class
|
||||
if (this is FirDefaultPropertyAccessor || this.source?.kind !is KtRealSourceElementKind) return false
|
||||
return hasModifier(KtTokens.EXTERNAL_KEYWORD) || hasAnnotation(JsNative, session)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isPrivateMemberOfExternalClass(session: FirSession): Boolean {
|
||||
if (this is FirPropertyAccessor && visibility == propertySymbol.visibility) return false
|
||||
if (this !is FirMemberDeclaration || visibility != Visibilities.Private) return false
|
||||
|
||||
val containingDeclaration = getContainingClassSymbol(session) ?: return false
|
||||
return containingDeclaration.isNativeObject(session)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isNonAbstractMemberIfInterface(session: FirSession): Boolean {
|
||||
return this is FirCallableDeclaration
|
||||
&& modality != Modality.ABSTRACT
|
||||
&& (getContainingClassSymbol(session) as? FirClassSymbol<*>)?.classKind == ClassKind.INTERFACE
|
||||
&& this !is FirPropertyAccessor
|
||||
}
|
||||
|
||||
private fun FirCallableDeclaration.isNullableProperty() = this is FirProperty && returnTypeRef.coneType.isNullable
|
||||
|
||||
private fun FirDeclaration.hasValidExternalBody(): Boolean {
|
||||
val body = when (this) {
|
||||
is FirFunction -> body
|
||||
is FirAnonymousInitializer -> body
|
||||
else -> return true
|
||||
}
|
||||
|
||||
return when {
|
||||
body is FirSingleExpressionBlock -> body.isDefinedExternallyExpression()
|
||||
body != null -> {
|
||||
val statement = body.statements.singleOrNull() ?: return false
|
||||
statement.isDefinedExternallyExpression()
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirElement.isDefinedExternallyExpression(): Boolean {
|
||||
val declaration = (this as? FirPropertyAccessExpression)
|
||||
?.calleeReference?.toResolvedPropertySymbol() ?: return false
|
||||
return declaration.callableId in JsStandardClassIds.Callables.definedExternallyPropertyNames
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.TO_STRING
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrors.CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrors.EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE
|
||||
|
||||
+1
@@ -19,5 +19,6 @@ object WasmDeclarationCheckers : DeclarationCheckers() {
|
||||
FirWasmJsInteropTypesChecker,
|
||||
FirWasmImportAnnotationChecker,
|
||||
FirWasmExportAnnotationChecker,
|
||||
FirWasmExternalChecker,
|
||||
)
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.wasm.checkers.declaration
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.web.common.FirWebCommonExternalChecker
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.WasmStandardClassIds
|
||||
|
||||
object FirWasmExternalChecker : FirWebCommonExternalChecker() {
|
||||
override fun isNativeOrEffectivelyExternal(symbol: FirBasedSymbol<*>, session: FirSession): Boolean {
|
||||
return symbol.isEffectivelyExternal(session)
|
||||
}
|
||||
|
||||
override fun reportExternalEnum(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "enum class", context)
|
||||
}
|
||||
|
||||
override fun additionalCheck(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (declaration is FirFunction) {
|
||||
if (declaration.isInline) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.INLINE_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
if (declaration.isTailRec) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "tailrec function", context)
|
||||
}
|
||||
if (declaration.isSuspend) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "suspend function", context)
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is FirProperty) {
|
||||
if (declaration.isLateInit) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "lateinit property", context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun isDefinedExternallyCallableId(callableId: CallableId): Boolean =
|
||||
callableId == WasmStandardClassIds.Callables.JsDefinedExternally
|
||||
|
||||
override fun hasExternalLikeAnnotations(declaration: FirDeclaration, session: FirSession): Boolean =
|
||||
false
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics.web.common
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
||||
import org.jetbrains.kotlin.psi.KtAnonymousInitializer
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.fir.checkers.generator.diagnostics.WEB_COMMON_DIAGNOSTICS_LIST]
|
||||
*/
|
||||
object FirWebCommonErrors {
|
||||
// Externals
|
||||
val NESTED_EXTERNAL_DECLARATION by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val WRONG_EXTERNAL_DECLARATION by error1<KtExpression, String>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NESTED_CLASS_IN_EXTERNAL_INTERFACE by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val INLINE_EXTERNAL_DECLARATION by error0<KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE by error0<KtExpression>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER by error0<KtParameter>()
|
||||
val EXTERNAL_ANONYMOUS_INITIALIZER by error0<KtAnonymousInitializer>()
|
||||
val EXTERNAL_DELEGATION by error0<KtElement>()
|
||||
val EXTERNAL_DELEGATED_CONSTRUCTOR_CALL by error0<KtElement>()
|
||||
val WRONG_BODY_OF_EXTERNAL_DECLARATION by error0<KtElement>()
|
||||
val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error0<KtElement>()
|
||||
val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error0<KtElement>()
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(FirWebCommonErrorsDefaultMessages)
|
||||
}
|
||||
}
|
||||
+256
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.web.common
|
||||
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.*
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
abstract class FirWebCommonExternalChecker : FirBasicDeclarationChecker() {
|
||||
abstract fun isNativeOrEffectivelyExternal(symbol: FirBasedSymbol<*>, session: FirSession): Boolean
|
||||
|
||||
abstract fun reportExternalEnum(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter)
|
||||
|
||||
abstract fun additionalCheck(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter)
|
||||
|
||||
abstract fun isDefinedExternallyCallableId(callableId: CallableId): Boolean
|
||||
|
||||
abstract fun hasExternalLikeAnnotations(declaration: FirDeclaration, session: FirSession): Boolean
|
||||
|
||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (!isNativeOrEffectivelyExternal(declaration.symbol, context.session)) return
|
||||
|
||||
if (!context.isTopLevel) {
|
||||
if (declaration !is FirPropertyAccessor && declaration.isDirectlyExternal(context.session)) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.NESTED_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is FirClass) {
|
||||
// TODO: KT-55600: Stop generating diagnostic
|
||||
// messages inside checkers
|
||||
val classKind = when {
|
||||
declaration.status.isData -> "data class"
|
||||
declaration.status.isInner -> "inner class"
|
||||
declaration.status.isInline -> "value class"
|
||||
declaration.status.isFun -> "fun interface"
|
||||
declaration.classKind == ClassKind.ANNOTATION_CLASS -> "annotation class"
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (classKind != null) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, classKind, context)
|
||||
}
|
||||
|
||||
if (declaration.isEnumClass) {
|
||||
reportExternalEnum(declaration, context, reporter)
|
||||
}
|
||||
}
|
||||
|
||||
if (declaration is FirPropertyAccessor && declaration.isDirectlyExternal(context.session)) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "property accessor", context)
|
||||
} else if (
|
||||
declaration !is FirPrimaryConstructor &&
|
||||
declaration !is FirField &&
|
||||
declaration.isPrivateMemberOfExternalClass(context.session)
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, "private member of class", context)
|
||||
}
|
||||
|
||||
val container = context.containingDeclarations.lastOrNull()
|
||||
|
||||
if (
|
||||
declaration is FirClass &&
|
||||
declaration.classKind != ClassKind.INTERFACE &&
|
||||
container is FirClass && container.classKind == ClassKind.INTERFACE
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE, context)
|
||||
}
|
||||
|
||||
if (declaration !is FirPropertyAccessor && declaration is FirCallableDeclaration && declaration.isExtension) {
|
||||
val target = when (declaration) {
|
||||
is FirFunction -> "extension function"
|
||||
is FirProperty -> "extension property"
|
||||
else -> "extension member"
|
||||
}
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION, target, context)
|
||||
}
|
||||
|
||||
if (
|
||||
declaration is FirCallableDeclaration &&
|
||||
declaration.isNonAbstractMemberIfInterface(context.session) &&
|
||||
!declaration.isNullableProperty()
|
||||
) {
|
||||
reporter.reportOn(declaration.source, FirWebCommonErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE, context)
|
||||
}
|
||||
|
||||
declaration.checkBody(context, reporter)
|
||||
declaration.checkDelegation(context, reporter)
|
||||
declaration.checkAnonymousInitializer(context, reporter)
|
||||
declaration.checkConstructorPropertyParam(context, reporter)
|
||||
|
||||
additionalCheck(declaration, context, reporter)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkBody(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this is FirDefaultPropertyAccessor) return
|
||||
|
||||
val body = when (this) {
|
||||
is FirFunction -> body
|
||||
is FirAnonymousInitializer -> body
|
||||
else -> null
|
||||
}
|
||||
|
||||
val initializer = when {
|
||||
this is FirEnumEntry -> null
|
||||
source?.kind == KtFakeSourceElementKind.PropertyFromParameter -> null
|
||||
this is FirVariable -> initializer
|
||||
body is FirSingleExpressionBlock -> (body.statement as? FirReturnExpression)?.result
|
||||
else -> null
|
||||
}
|
||||
|
||||
// we shouldn't check such things as the
|
||||
// copy() function of a data class
|
||||
if (source?.kind !is KtRealSourceElementKind) {
|
||||
return
|
||||
}
|
||||
|
||||
val isWrong = body !is FirSingleExpressionBlock && !hasValidExternalBody()
|
||||
|| initializer != null && !initializer.isDefinedExternallyExpression()
|
||||
|
||||
if (isWrong && body != null) {
|
||||
reporter.reportOn(body.source, FirWebCommonErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION, context)
|
||||
} else if (isWrong && initializer != null) {
|
||||
reporter.reportOn(initializer.source, FirWebCommonErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION, context)
|
||||
}
|
||||
|
||||
if (this is FirFunction) {
|
||||
for (defaultValue in valueParameters.mapNotNull { it.defaultValue }) {
|
||||
if (!defaultValue.isDefinedExternallyExpression()) {
|
||||
reporter.reportOn(defaultValue.source, FirWebCommonErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkDelegation(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirMemberDeclaration || !isNativeOrEffectivelyExternal(symbol, context.session)) return
|
||||
|
||||
if (this is FirClass) {
|
||||
declarations.firstIsInstanceOrNull<FirPrimaryConstructor>()?.let {
|
||||
val constructorCall = it.delegatedConstructor
|
||||
|
||||
if (constructorCall?.source?.kind is KtRealSourceElementKind) {
|
||||
reporter.reportOn(constructorCall.source, FirWebCommonErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, context)
|
||||
}
|
||||
}
|
||||
|
||||
for ((superType, delegate) in collectSupertypesWithDelegates()) {
|
||||
when {
|
||||
delegate != null -> {
|
||||
reporter.reportOn(superType.source, FirWebCommonErrors.EXTERNAL_DELEGATION, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this is FirConstructor && !isPrimary) {
|
||||
val delegationCall = delegatedConstructor
|
||||
|
||||
if (delegationCall?.source?.kind is KtRealSourceElementKind) {
|
||||
reporter.reportOn(delegationCall.source, FirWebCommonErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, context)
|
||||
}
|
||||
} else if (this is FirProperty) {
|
||||
delegate?.let {
|
||||
reporter.reportOn(it.source, FirWebCommonErrors.EXTERNAL_DELEGATION, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkAnonymousInitializer(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirClass) return
|
||||
|
||||
for (anonymousInitializer in anonymousInitializers) {
|
||||
reporter.reportOn(anonymousInitializer.source, FirWebCommonErrors.EXTERNAL_ANONYMOUS_INITIALIZER, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.checkConstructorPropertyParam(context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (this !is FirProperty || source?.kind != KtFakeSourceElementKind.PropertyFromParameter) return
|
||||
val containingClass = getContainingClassSymbol(context.session) as? FirClassSymbol<*> ?: return
|
||||
if (containingClass.isData || containingClass.classKind == ClassKind.ANNOTATION_CLASS) return
|
||||
reporter.reportOn(source, FirWebCommonErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, context)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isDirectlyExternal(session: FirSession): Boolean {
|
||||
// source kind is checked, otherwise this function
|
||||
// may return true for a primary constructor of an external class
|
||||
if (this is FirDefaultPropertyAccessor || this.source?.kind !is KtRealSourceElementKind) return false
|
||||
return hasModifier(KtTokens.EXTERNAL_KEYWORD) || hasExternalLikeAnnotations(this, session)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isPrivateMemberOfExternalClass(session: FirSession): Boolean {
|
||||
if (this is FirPropertyAccessor && visibility == propertySymbol.visibility) return false
|
||||
if (this !is FirMemberDeclaration || visibility != Visibilities.Private) return false
|
||||
|
||||
val containingDeclaration = getContainingClassSymbol(session) ?: return false
|
||||
return isNativeOrEffectivelyExternal(containingDeclaration, session)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isNonAbstractMemberIfInterface(session: FirSession): Boolean {
|
||||
return this is FirCallableDeclaration
|
||||
&& modality != Modality.ABSTRACT
|
||||
&& (getContainingClassSymbol(session) as? FirClassSymbol<*>)?.classKind == ClassKind.INTERFACE
|
||||
&& this !is FirPropertyAccessor
|
||||
}
|
||||
|
||||
private fun FirCallableDeclaration.isNullableProperty() = this is FirProperty && returnTypeRef.coneType.isNullable
|
||||
|
||||
private fun FirDeclaration.hasValidExternalBody(): Boolean {
|
||||
val body = when (this) {
|
||||
is FirFunction -> body
|
||||
is FirAnonymousInitializer -> body
|
||||
else -> return true
|
||||
}
|
||||
|
||||
return when {
|
||||
body is FirSingleExpressionBlock -> body.isDefinedExternallyExpression()
|
||||
body != null -> {
|
||||
val statement = body.statements.singleOrNull() ?: return false
|
||||
statement.isDefinedExternallyExpression()
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirElement.isDefinedExternallyExpression(): Boolean {
|
||||
val declaration = (this as? FirPropertyAccessExpression)
|
||||
?.calleeReference?.toResolvedPropertySymbol() ?: return false
|
||||
return isDefinedExternallyCallableId(declaration.callableId)
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics.web.common
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.EXTERNAL_ANONYMOUS_INITIALIZER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.EXTERNAL_DELEGATED_CONSTRUCTOR_CALL
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.EXTERNAL_DELEGATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.INLINE_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.NESTED_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.WRONG_BODY_OF_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.WRONG_EXTERNAL_DECLARATION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION
|
||||
|
||||
@Suppress("unused")
|
||||
object FirWebCommonErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
override val MAP = KtDiagnosticFactoryToRendererMap("FIR").also { map ->
|
||||
map.put(NESTED_EXTERNAL_DECLARATION, "Non-top-level 'external' declaration.")
|
||||
map.put(WRONG_EXTERNAL_DECLARATION, "Declaration of such kind ({0}) cannot be external.", CommonRenderers.STRING)
|
||||
map.put(NESTED_CLASS_IN_EXTERNAL_INTERFACE, "Interface cannot contain nested classes and objects.")
|
||||
map.put(INLINE_EXTERNAL_DECLARATION, "Inline external declaration.")
|
||||
map.put(
|
||||
NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE,
|
||||
"Only nullable properties of external interfaces are allowed to be non-abstract."
|
||||
)
|
||||
map.put(EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, "External class constructor cannot have a property parameter.")
|
||||
map.put(EXTERNAL_ANONYMOUS_INITIALIZER, "Anonymous initializers in external classes are prohibited.")
|
||||
map.put(EXTERNAL_DELEGATION, "Cannot use delegate on external declaration.")
|
||||
map.put(EXTERNAL_DELEGATED_CONSTRUCTOR_CALL, "Delegated constructor call in external class is prohibited.")
|
||||
map.put(
|
||||
WRONG_BODY_OF_EXTERNAL_DECLARATION,
|
||||
"Wrong body of external declaration. Must be either ' = definedExternally' or '{ definedExternally }'."
|
||||
)
|
||||
map.put(WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION, "Wrong initializer of external declaration. Must be ' = definedExternally'.")
|
||||
map.put(
|
||||
WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER,
|
||||
"Wrong default value for parameter of external function. Must be ' = definedExternally'."
|
||||
)
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -623,22 +623,10 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(
|
||||
"OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS",
|
||||
"OVERRIDING_EXTERNAL_FUN_WITH_OPTIONAL_PARAMS_WITH_FAKE",
|
||||
"CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION",
|
||||
"EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
|
||||
"EXTERNAL_ENUM_ENTRY_WITH_BODY",
|
||||
"EXTERNAL_ANONYMOUS_INITIALIZER",
|
||||
"EXTERNAL_DELEGATION",
|
||||
"EXTERNAL_DELEGATED_CONSTRUCTOR_CALL",
|
||||
"WRONG_BODY_OF_EXTERNAL_DECLARATION",
|
||||
"WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION",
|
||||
"WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER",
|
||||
"NESTED_EXTERNAL_DECLARATION",
|
||||
"WRONG_EXTERNAL_DECLARATION",
|
||||
"NESTED_CLASS_IN_EXTERNAL_INTERFACE",
|
||||
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
|
||||
"INLINE_EXTERNAL_DECLARATION",
|
||||
"INLINE_CLASS_IN_EXTERNAL_DECLARATION",
|
||||
"EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION",
|
||||
"NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE",
|
||||
"NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
|
||||
"CANNOT_CHECK_FOR_EXTERNAL_INTERFACE",
|
||||
"EXTERNAL_INTERFACE_AS_CLASS_LITERAL",
|
||||
@@ -677,5 +665,17 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(
|
||||
"CANNOT_CHECK_FOR_FORWARD_DECLARATION",
|
||||
"FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT",
|
||||
"FORWARD_DECLARATION_AS_CLASS_LITERAL",
|
||||
"NESTED_EXTERNAL_DECLARATION",
|
||||
"WRONG_EXTERNAL_DECLARATION",
|
||||
"NESTED_CLASS_IN_EXTERNAL_INTERFACE",
|
||||
"INLINE_EXTERNAL_DECLARATION",
|
||||
"NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE",
|
||||
"EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER",
|
||||
"EXTERNAL_ANONYMOUS_INITIALIZER",
|
||||
"EXTERNAL_DELEGATION",
|
||||
"EXTERNAL_DELEGATED_CONSTRUCTOR_CALL",
|
||||
"WRONG_BODY_OF_EXTERNAL_DECLARATION",
|
||||
"WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION",
|
||||
"WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER",
|
||||
"SYNTAX",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// FIR_IDENTICAL
|
||||
external class A {
|
||||
<!EXTERNAL_ANONYMOUS_INITIALIZER!>init {
|
||||
definedExternally
|
||||
}<!>
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// FIR_IDENTICAL
|
||||
external fun foo(): Int = definedExternally
|
||||
|
||||
external fun bar(): Unit {
|
||||
definedExternally
|
||||
}
|
||||
|
||||
external fun baz(): Int = <!WRONG_BODY_OF_EXTERNAL_DECLARATION!>23<!>
|
||||
|
||||
external fun f(x: Int, y: String = definedExternally): Unit
|
||||
|
||||
external fun g(x: Int, y: String = <!WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER!>""<!>): Unit
|
||||
|
||||
external var a: Int
|
||||
get() = definedExternally
|
||||
set(value) {
|
||||
definedExternally
|
||||
}
|
||||
|
||||
external val b: Int
|
||||
get() = <!WRONG_BODY_OF_EXTERNAL_DECLARATION!>23<!>
|
||||
|
||||
external val c: Int = definedExternally
|
||||
|
||||
external val d: Int = <!WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION!>23<!>
|
||||
|
||||
external class C {
|
||||
fun foo(): Int = definedExternally
|
||||
|
||||
fun bar(): Int = <!WRONG_BODY_OF_EXTERNAL_DECLARATION!>23<!>
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
external open class Base(x: Int) {
|
||||
constructor(x: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>this<!>(23)
|
||||
|
||||
constructor(x: String, y: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>this<!>("")
|
||||
}
|
||||
|
||||
external open class Derived1() : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>Base(23)<!> {
|
||||
constructor(x: Byte) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>(23)
|
||||
|
||||
constructor(x: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>("")
|
||||
|
||||
constructor(x: String, y: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>("")
|
||||
}
|
||||
|
||||
external open class Derived2() : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>Base("")<!>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
external open class Base(x: Int) {
|
||||
constructor(x: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>this<!>(23)
|
||||
|
||||
constructor(x: String, y: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>this<!>("")
|
||||
}
|
||||
|
||||
external open class Derived1() : Base<!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>(23)<!> {
|
||||
constructor(x: Byte) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>(23)
|
||||
|
||||
constructor(x: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>("")
|
||||
|
||||
constructor(x: String, y: String) : <!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>super<!>("")
|
||||
}
|
||||
|
||||
external open class Derived2() : Base<!EXTERNAL_DELEGATED_CONSTRUCTOR_CALL!>("")<!>
|
||||
@@ -0,0 +1,18 @@
|
||||
external interface I
|
||||
|
||||
external object O : I
|
||||
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(thisRef: Any?, property: Any): String = ""
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: Any, value: String) {}
|
||||
}
|
||||
|
||||
external class A : <!EXTERNAL_DELEGATION!>I<!> by O {
|
||||
val prop by <!EXTERNAL_DELEGATION!>Delegate()<!>
|
||||
|
||||
var mutableProp by <!EXTERNAL_DELEGATION!>Delegate()<!>
|
||||
}
|
||||
|
||||
external val topLevelProp by <!EXTERNAL_DELEGATION!>Delegate()<!>
|
||||
@@ -0,0 +1,18 @@
|
||||
external interface I
|
||||
|
||||
external object O : I
|
||||
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(thisRef: Any?, property: Any): String = ""
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: Any, value: String) {}
|
||||
}
|
||||
|
||||
external class A : <!EXTERNAL_DELEGATION!>I by O<!> {
|
||||
val prop <!EXTERNAL_DELEGATION!>by Delegate()<!>
|
||||
|
||||
var mutableProp <!EXTERNAL_DELEGATION!>by Delegate()<!>
|
||||
}
|
||||
|
||||
external val topLevelProp <!EXTERNAL_DELEGATION!>by Delegate()<!>
|
||||
@@ -1,51 +0,0 @@
|
||||
|
||||
// Classes
|
||||
|
||||
external class C1
|
||||
|
||||
external enum class C2
|
||||
|
||||
external annotation class C3
|
||||
|
||||
external data class C4(val x: String)
|
||||
|
||||
external class C5 {
|
||||
|
||||
class C6
|
||||
|
||||
inner class C7
|
||||
}
|
||||
|
||||
external inline class C8(val x: Int)
|
||||
|
||||
external value class C9(val x: Int)
|
||||
|
||||
|
||||
// Interfaces
|
||||
|
||||
external interface I1
|
||||
|
||||
external fun interface I2 {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
external fun foo1(): Int
|
||||
|
||||
external <!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo2(): Int
|
||||
|
||||
external inline fun foo3(f: () -> Int): Int
|
||||
|
||||
external suspend fun foo4(): Int
|
||||
|
||||
external fun Int.foo5(): Int
|
||||
|
||||
|
||||
// Properties
|
||||
|
||||
external lateinit var v1: String
|
||||
|
||||
external val Int.v2: String
|
||||
get() = definedExternally
|
||||
@@ -1,3 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -INLINE_CLASS_DEPRECATED -NO_TAIL_CALLS_FOUND
|
||||
|
||||
// Classes
|
||||
|
||||
@@ -16,7 +18,7 @@ external class C5 {
|
||||
inner class <!WRONG_EXTERNAL_DECLARATION!>C7<!>
|
||||
}
|
||||
|
||||
external <!INLINE_CLASS_DEPRECATED!>inline<!> class <!WRONG_EXTERNAL_DECLARATION!>C8(<!EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER!>val x: Int<!>)<!>
|
||||
external inline class <!WRONG_EXTERNAL_DECLARATION!>C8(<!EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER!>val x: Int<!>)<!>
|
||||
|
||||
external value class <!WRONG_EXTERNAL_DECLARATION!>C9(<!EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER!>val x: Int<!>)<!>
|
||||
|
||||
@@ -48,4 +50,8 @@ external fun foo1(): Int
|
||||
<!WRONG_EXTERNAL_DECLARATION!>external lateinit var v1: String<!>
|
||||
|
||||
<!WRONG_EXTERNAL_DECLARATION!>external val Int.v2: String<!>
|
||||
get() = definedExternally
|
||||
get() = definedExternally
|
||||
|
||||
|
||||
// Property parameters
|
||||
external class C(x: Int, <!EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER!>val y: String<!>)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
external interface I {
|
||||
interface J
|
||||
|
||||
class <!NESTED_CLASS_IN_EXTERNAL_INTERFACE!>C<!>
|
||||
|
||||
<!NESTED_CLASS_IN_EXTERNAL_INTERFACE!>object O<!>
|
||||
|
||||
enum class <!NESTED_CLASS_IN_EXTERNAL_INTERFACE, WRONG_EXTERNAL_DECLARATION!>E<!>
|
||||
|
||||
companion <!NESTED_CLASS_IN_EXTERNAL_INTERFACE!>object<!>
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// FIR_IDENTICAL
|
||||
object O
|
||||
|
||||
class TopLevel {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
|
||||
val x = "a"
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val y: String<!>
|
||||
|
||||
val O.u: String get() = "O.u"
|
||||
}
|
||||
|
||||
external class TopLevelNative {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo(): Int = definedExternally
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
|
||||
val x: String = definedExternally
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val y: String<!>
|
||||
}
|
||||
|
||||
fun topLevelFun() {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// FIR_IDENTICAL
|
||||
external interface I {
|
||||
<!NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE!>fun foo(): Unit<!> = definedExternally
|
||||
|
||||
val a: Int?
|
||||
get() = definedExternally
|
||||
|
||||
var b: String?
|
||||
get() = definedExternally
|
||||
set(value) = definedExternally
|
||||
|
||||
<!NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE!>val c: Int<!>
|
||||
get() = definedExternally
|
||||
|
||||
<!NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE!>var d: String<!>
|
||||
get() = definedExternally
|
||||
set(value) = definedExternally
|
||||
}
|
||||
@@ -13,6 +13,10 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrorsDefaultMessages
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.native.FirNativeErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.native.FirNativeErrorsDefaultMessages
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.wasm.FirWasmErrorsDefaultMessages
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrorsDefaultMessages
|
||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrorsDefaultMessages
|
||||
import org.jetbrains.kotlin.test.utils.verifyMessages
|
||||
@@ -25,6 +29,8 @@ class DefaultMessagesTest {
|
||||
FirJvmErrorsDefaultMessages.MAP.verifyMessages(FirJvmErrors)
|
||||
FirJsErrorsDefaultMessages.MAP.verifyMessages(FirJsErrors)
|
||||
FirNativeErrorsDefaultMessages.MAP.verifyMessages(FirNativeErrors)
|
||||
FirWasmErrorsDefaultMessages.MAP.verifyMessages(FirWasmErrors)
|
||||
FirWebCommonErrorsDefaultMessages.MAP.verifyMessages(FirWebCommonErrors)
|
||||
FirSyntaxErrorsDefaultMessages.MAP.verifyMessages(FirSyntaxErrors)
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
|
||||
// TODO: Implement in K2: KT-56849
|
||||
object WasmExternalDeclarationChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (descriptor !is MemberDescriptor || !descriptor.isEffectivelyExternal())
|
||||
|
||||
+42
@@ -33,12 +33,36 @@ public class DiagnosticsFirWasmTestGenerated extends AbstractDiagnosticsFirWasmT
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousInitializer.kt")
|
||||
public void testAnonymousInitializer() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/anonymousInitializer.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("body.kt")
|
||||
public void testBody() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/body.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("definedExternally.kt")
|
||||
public void testDefinedExternally() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/definedExternally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall.kt")
|
||||
public void testDelegatedConstructorCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/delegatedConstructorCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/delegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicUnsupported.kt")
|
||||
public void testDynamicUnsupported() throws Exception {
|
||||
@@ -51,6 +75,12 @@ public class DiagnosticsFirWasmTestGenerated extends AbstractDiagnosticsFirWasmT
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/external.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInterfaceNested.kt")
|
||||
public void testExternalInterfaceNested() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/externalInterfaceNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
@@ -75,6 +105,18 @@ public class DiagnosticsFirWasmTestGenerated extends AbstractDiagnosticsFirWasmT
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedExternal.kt")
|
||||
public void testNestedExternal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/nestedExternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonAbstractMembersOfInterface.kt")
|
||||
public void testNonAbstractMembersOfInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/nonAbstractMembersOfInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
|
||||
+42
@@ -33,12 +33,36 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousInitializer.kt")
|
||||
public void testAnonymousInitializer() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/anonymousInitializer.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("body.kt")
|
||||
public void testBody() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/body.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("definedExternally.kt")
|
||||
public void testDefinedExternally() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/definedExternally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall.kt")
|
||||
public void testDelegatedConstructorCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/delegatedConstructorCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/delegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicUnsupported.kt")
|
||||
public void testDynamicUnsupported() throws Exception {
|
||||
@@ -51,6 +75,12 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/external.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalInterfaceNested.kt")
|
||||
public void testExternalInterfaceNested() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/externalInterfaceNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
@@ -75,6 +105,18 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedExternal.kt")
|
||||
public void testNestedExternal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/nestedExternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonAbstractMembersOfInterface.kt")
|
||||
public void testNonAbstractMembersOfInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/nonAbstractMembersOfInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user