diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt index 32244febf6d..5a77b01f955 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt @@ -93,14 +93,6 @@ object JS_DIAGNOSTICS_LIST : DiagnosticList("FirJsErrors") { val NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { parameter("type") } - val CANNOT_CHECK_FOR_EXTERNAL_INTERFACE by error { - parameter("targetType") - } - val UNCHECKED_CAST_TO_EXTERNAL_INTERFACE by warning { - parameter("sourceType") - parameter("targetType") - } - val EXTERNAL_INTERFACE_AS_CLASS_LITERAL by error() val JS_EXTERNAL_INHERITORS_ONLY by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { parameter>("parent") parameter>("kid") @@ -108,9 +100,6 @@ object JS_DIAGNOSTICS_LIST : DiagnosticList("FirJsErrors") { val JS_EXTERNAL_ARGUMENT by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { parameter("argType") } - val EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { - parameter("typeArgument") - } } val EXPORT by object : DiagnosticGroup("Export") { diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirWebCommonDiagnosticList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirWebCommonDiagnosticList.kt index 74c1feb42c3..322e7f9a6b9 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirWebCommonDiagnosticList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirWebCommonDiagnosticList.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.checkers.generator.diagnostics 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 @@ -32,6 +33,17 @@ object WEB_COMMON_DIAGNOSTICS_LIST : DiagnosticList("FirWebCommonErrors") { val WRONG_BODY_OF_EXTERNAL_DECLARATION by error() val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error() val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error() + val CANNOT_CHECK_FOR_EXTERNAL_INTERFACE by error { + parameter("targetType") + } + val UNCHECKED_CAST_TO_EXTERNAL_INTERFACE by warning { + parameter("sourceType") + parameter("targetType") + } + val EXTERNAL_INTERFACE_AS_CLASS_LITERAL by error() + val EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { + parameter("typeArgument") + } } val EXPORT by object : DiagnosticGroup("Export") { diff --git a/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt b/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt index 6c47f67d30e..bb044d9c338 100644 --- a/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt +++ b/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt @@ -67,12 +67,8 @@ object FirJsErrors { val INLINE_CLASS_IN_EXTERNAL_DECLARATION by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) - val CANNOT_CHECK_FOR_EXTERNAL_INTERFACE by error1() - val UNCHECKED_CAST_TO_EXTERNAL_INTERFACE by warning2() - val EXTERNAL_INTERFACE_AS_CLASS_LITERAL by error0() val JS_EXTERNAL_INHERITORS_ONLY by error2, FirClassLikeSymbol<*>>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val JS_EXTERNAL_ARGUMENT by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) - val EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) // Export val WRONG_EXPORTED_DECLARATION by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt index 40011480cf8..197a8c5da9a 100644 --- a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt @@ -14,13 +14,10 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CALL_FROM_UM import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION 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.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 @@ -55,7 +52,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.PROPERTY_DEL 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_EXPORTED_DECLARATION 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 @@ -155,11 +151,6 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() { "Expected argument with external type, but type ''{0}'' is non-external.", FirDiagnosticRenderers.RENDER_TYPE ) - map.put( - EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, - "Cannot pass external interface ''{0}'' for reified type parameter.", - FirDiagnosticRenderers.RENDER_TYPE - ) map.put(JS_NAME_PROHIBITED_FOR_EXTENSION_PROPERTY, "'@JsName' is prohibited for extension properties.") map.put( JS_BUILTIN_NAME_CLASH, @@ -186,18 +177,6 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() { map.put(JS_NAME_PROHIBITED_FOR_OVERRIDE, "'@JsName' is prohibited for overridden members.") map.put(JS_NAME_ON_PRIMARY_CONSTRUCTOR_PROHIBITED, "'@JsName' annotation is prohibited for primary constructors.") map.put(JS_NAME_ON_ACCESSOR_AND_PROPERTY, "'@JsName' can be either on a property or its accessors, not both of them.") - map.put( - CANNOT_CHECK_FOR_EXTERNAL_INTERFACE, - "Cannot check for external interface: ''{0}''", - FirDiagnosticRenderers.RENDER_TYPE, - ) - map.put( - UNCHECKED_CAST_TO_EXTERNAL_INTERFACE, - "Unchecked cast to external interface: ''{0}'' to ''{1}''.", - FirDiagnosticRenderers.RENDER_TYPE, - FirDiagnosticRenderers.RENDER_TYPE, - ) - map.put(EXTERNAL_INTERFACE_AS_CLASS_LITERAL, "Cannot refer to external interface from class literal.") map.put(WRONG_EXPORTED_DECLARATION, "Declaration of such kind ({0}) cannot be exported to JavaScript.", CommonRenderers.STRING) map.put( NON_EXPORTABLE_TYPE, diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/FirJsWebCheckerUtils.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/FirJsWebCheckerUtils.kt new file mode 100644 index 00000000000..51a28471729 --- /dev/null +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/FirJsWebCheckerUtils.kt @@ -0,0 +1,16 @@ +/* + * 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.js.checkers + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.FirAbstractWebCheckerUtils +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol + +object FirJsWebCheckerUtils : FirAbstractWebCheckerUtils() { + override fun isNativeOrExternalInterface(symbol: FirBasedSymbol<*>, session: FirSession): Boolean { + return symbol.isNativeInterface(session) + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsNativeRttiChecker.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsNativeRttiChecker.kt index a5d08d5a1c9..e2f45e981ca 100644 --- a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsNativeRttiChecker.kt +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsNativeRttiChecker.kt @@ -5,62 +5,7 @@ package org.jetbrains.kotlin.fir.analysis.js.checkers.expression -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.diagnostics.reportOn -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirBasicExpressionChecker -import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol -import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors -import org.jetbrains.kotlin.fir.analysis.js.checkers.isNativeInterface -import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.types.coneType -import org.jetbrains.kotlin.fir.types.resolvedType -import org.jetbrains.kotlin.fir.types.toRegularClassSymbol +import org.jetbrains.kotlin.fir.analysis.js.checkers.FirJsWebCheckerUtils +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirAbstractNativeRttiChecker -object FirJsNativeRttiChecker : FirBasicExpressionChecker() { - override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) { - when (expression) { - is FirGetClassCall -> checkGetClassCall(expression, context, reporter) - is FirTypeOperatorCall -> checkTypeOperatorCall(expression, context, reporter) - else -> {} - } - } - - private fun checkGetClassCall(expression: FirGetClassCall, context: CheckerContext, reporter: DiagnosticReporter) { - val declarationToCheck = expression.argument.resolvedType.toRegularClassSymbol(context.session) ?: return - - if (expression.arguments.firstOrNull() !is FirResolvedQualifier) { - return - } - - if (declarationToCheck.isNativeInterface(context)) { - reporter.reportOn(expression.source, FirJsErrors.EXTERNAL_INTERFACE_AS_CLASS_LITERAL, context) - } - } - - private fun checkTypeOperatorCall(expression: FirTypeOperatorCall, context: CheckerContext, reporter: DiagnosticReporter) { - val targetTypeRef = expression.conversionTypeRef - val declarationToCheck = targetTypeRef.toRegularClassSymbol(context.session) ?: return - - if (!declarationToCheck.isNativeInterface(context)) { - return - } - - when (expression.operation) { - FirOperation.AS, FirOperation.SAFE_AS -> reporter.reportOn( - expression.source, - FirJsErrors.UNCHECKED_CAST_TO_EXTERNAL_INTERFACE, - expression.argument.resolvedType, - targetTypeRef.coneType, - context, - ) - FirOperation.IS, FirOperation.NOT_IS -> reporter.reportOn( - expression.source, - FirJsErrors.CANNOT_CHECK_FOR_EXTERNAL_INTERFACE, - targetTypeRef.coneType, - context, - ) - else -> {} - } - } -} +object FirJsNativeRttiChecker : FirAbstractNativeRttiChecker(FirJsWebCheckerUtils) diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsReifiedExternalChecker.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsReifiedExternalChecker.kt index 1ac3d12094e..c53c0b232d4 100644 --- a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsReifiedExternalChecker.kt +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/expression/FirJsReifiedExternalChecker.kt @@ -5,28 +5,7 @@ package org.jetbrains.kotlin.fir.analysis.js.checkers.expression -import org.jetbrains.kotlin.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.diagnostics.reportOn -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker -import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors -import org.jetbrains.kotlin.fir.analysis.js.checkers.isNativeInterface -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall -import org.jetbrains.kotlin.fir.expressions.forAllReifiedTypeParameters -import org.jetbrains.kotlin.fir.types.toSymbol +import org.jetbrains.kotlin.fir.analysis.js.checkers.FirJsWebCheckerUtils +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirAbstractReifiedExternalChecker -object FirJsReifiedExternalChecker : FirFunctionCallChecker() { - override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { - expression.forAllReifiedTypeParameters { type, typeArgument -> - val typeSymbol = type.toSymbol(context.session) - if (typeSymbol?.isNativeInterface(context) == true) { - reporter.reportOn( - typeArgument.source ?: expression.source, - FirJsErrors.EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, - type, - context - ) - } - } - } -} +object FirJsReifiedExternalChecker : FirAbstractReifiedExternalChecker(FirJsWebCheckerUtils) diff --git a/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/FirWasmWebCheckerUtils.kt b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/FirWasmWebCheckerUtils.kt new file mode 100644 index 00000000000..ebe7d1c9e63 --- /dev/null +++ b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/FirWasmWebCheckerUtils.kt @@ -0,0 +1,20 @@ +/* + * 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 + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.FirAbstractWebCheckerUtils +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.utils.isEffectivelyExternal +import org.jetbrains.kotlin.fir.declarations.utils.isInterface +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.SymbolInternals + +object FirWasmWebCheckerUtils : FirAbstractWebCheckerUtils() { + @OptIn(SymbolInternals::class) + override fun isNativeOrExternalInterface(symbol: FirBasedSymbol<*>, session: FirSession): Boolean = + symbol.isEffectivelyExternal(session) && (symbol.fir as? FirClass)?.isInterface == true +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/WasmExpressionCheckers.kt b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/WasmExpressionCheckers.kt index 391663b4c9f..30f2e4721bb 100644 --- a/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/WasmExpressionCheckers.kt +++ b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/WasmExpressionCheckers.kt @@ -7,7 +7,9 @@ package org.jetbrains.kotlin.fir.analysis.wasm.checkers import org.jetbrains.kotlin.fir.analysis.checkers.expression.* import org.jetbrains.kotlin.fir.analysis.wasm.checkers.expression.FirWasmDefinedExternallyCallChecker +import org.jetbrains.kotlin.fir.analysis.wasm.checkers.expression.FirWasmExternalRttiChecker import org.jetbrains.kotlin.fir.analysis.wasm.checkers.expression.FirWasmJsCodeCallChecker +import org.jetbrains.kotlin.fir.analysis.wasm.checkers.expression.FirWasmReifiedExternalChecker import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirJsCodeConstantArgumentChecker import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirJsQualifierChecker @@ -20,11 +22,13 @@ object WasmExpressionCheckers : ExpressionCheckers() { override val basicExpressionCheckers: Set get() = setOf( FirWasmDefinedExternallyCallChecker, + FirWasmExternalRttiChecker, ) override val functionCallCheckers: Set get() = setOf( FirJsCodeConstantArgumentChecker, FirWasmJsCodeCallChecker, + FirWasmReifiedExternalChecker ) } diff --git a/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmExternalRttiChecker.kt b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmExternalRttiChecker.kt new file mode 100644 index 00000000000..e886211693e --- /dev/null +++ b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmExternalRttiChecker.kt @@ -0,0 +1,11 @@ +/* + * 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.expression + +import org.jetbrains.kotlin.fir.analysis.wasm.checkers.FirWasmWebCheckerUtils +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirAbstractNativeRttiChecker + +object FirWasmExternalRttiChecker : FirAbstractNativeRttiChecker(FirWasmWebCheckerUtils) \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmReifiedExternalChecker.kt b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmReifiedExternalChecker.kt new file mode 100644 index 00000000000..aa36e054184 --- /dev/null +++ b/compiler/fir/checkers/checkers.wasm/src/org/jetbrains/kotlin/fir/analysis/wasm/checkers/expression/FirWasmReifiedExternalChecker.kt @@ -0,0 +1,11 @@ +/* + * 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.expression + +import org.jetbrains.kotlin.fir.analysis.wasm.checkers.FirWasmWebCheckerUtils +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.expression.FirAbstractReifiedExternalChecker + +object FirWasmReifiedExternalChecker : FirAbstractReifiedExternalChecker(FirWasmWebCheckerUtils) \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.web.common/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrors.kt b/compiler/fir/checkers/checkers.web.common/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrors.kt index ef801b1632c..8e19b9b15eb 100644 --- a/compiler/fir/checkers/checkers.web.common/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrors.kt +++ b/compiler/fir/checkers/checkers.web.common/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrors.kt @@ -9,6 +9,7 @@ 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.fir.types.ConeKotlinType import org.jetbrains.kotlin.psi.KtAnonymousInitializer import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement @@ -35,6 +36,10 @@ object FirWebCommonErrors { val WRONG_BODY_OF_EXTERNAL_DECLARATION by error0() val WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION by error0() val WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER by error0() + val CANNOT_CHECK_FOR_EXTERNAL_INTERFACE by error1() + val UNCHECKED_CAST_TO_EXTERNAL_INTERFACE by warning2() + val EXTERNAL_INTERFACE_AS_CLASS_LITERAL by error0() + val EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) // Export val NESTED_JS_EXPORT by error0() diff --git a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrorsDefaultMessages.kt b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrorsDefaultMessages.kt index d9dc43cb2c0..b5f726b4948 100644 --- a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/diagnostics/web/common/FirWebCommonErrorsDefaultMessages.kt @@ -8,16 +8,21 @@ 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.FirDiagnosticRenderers +import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.CANNOT_CHECK_FOR_EXTERNAL_INTERFACE 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.EXTERNAL_INTERFACE_AS_CLASS_LITERAL +import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.INLINE_EXTERNAL_DECLARATION import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors.JSCODE_ARGUMENT_NON_CONST_EXPRESSION 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.NESTED_JS_EXPORT 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.UNCHECKED_CAST_TO_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 @@ -49,6 +54,24 @@ object FirWebCommonErrorsDefaultMessages : BaseDiagnosticRendererFactory() { WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER, "Wrong default value for parameter of external function. Must be ' = definedExternally'." ) + map.put( + CANNOT_CHECK_FOR_EXTERNAL_INTERFACE, + "Cannot check for external interface: ''{0}''", + FirDiagnosticRenderers.RENDER_TYPE, + ) + map.put( + UNCHECKED_CAST_TO_EXTERNAL_INTERFACE, + "Unchecked cast to external interface: ''{0}'' to ''{1}''.", + FirDiagnosticRenderers.RENDER_TYPE, + FirDiagnosticRenderers.RENDER_TYPE, + ) + map.put(EXTERNAL_INTERFACE_AS_CLASS_LITERAL, "Cannot refer to external interface from class literal.") + map.put( + EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, + "Cannot pass external interface ''{0}'' for reified type parameter.", + FirDiagnosticRenderers.RENDER_TYPE + ) + map.put(NESTED_JS_EXPORT, "'@JsExport' is only allowed on files and top-level declarations.") diff --git a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/FirAbstractWebCheckerUtils.kt b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/FirAbstractWebCheckerUtils.kt new file mode 100644 index 00000000000..d93b9c5c198 --- /dev/null +++ b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/FirAbstractWebCheckerUtils.kt @@ -0,0 +1,13 @@ +/* + * 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.checkers + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol + +abstract class FirAbstractWebCheckerUtils { + abstract fun isNativeOrExternalInterface(symbol: FirBasedSymbol<*>, session: FirSession): Boolean +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractNativeRttiChecker.kt b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractNativeRttiChecker.kt new file mode 100644 index 00000000000..551c74b4258 --- /dev/null +++ b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractNativeRttiChecker.kt @@ -0,0 +1,68 @@ +/* + * 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.checkers.expression + +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirBasicExpressionChecker +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClassSymbol +import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.FirAbstractWebCheckerUtils +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.types.coneType +import org.jetbrains.kotlin.fir.types.resolvedType +import org.jetbrains.kotlin.fir.types.toRegularClassSymbol + +abstract class FirAbstractNativeRttiChecker( + private val webCheckerUtils: FirAbstractWebCheckerUtils +) : FirBasicExpressionChecker() { + override fun check(expression: FirStatement, context: CheckerContext, reporter: DiagnosticReporter) { + when (expression) { + is FirGetClassCall -> checkGetClassCall(expression, context, reporter) + is FirTypeOperatorCall -> checkTypeOperatorCall(expression, context, reporter) + else -> {} + } + } + + private fun checkGetClassCall(expression: FirGetClassCall, context: CheckerContext, reporter: DiagnosticReporter) { + val declarationToCheck = expression.argument.resolvedType.toRegularClassSymbol(context.session) ?: return + + if (expression.arguments.firstOrNull() !is FirResolvedQualifier) { + return + } + + if (webCheckerUtils.isNativeOrExternalInterface(declarationToCheck, context.session)) { + reporter.reportOn(expression.source, FirWebCommonErrors.EXTERNAL_INTERFACE_AS_CLASS_LITERAL, context) + } + } + + private fun checkTypeOperatorCall(expression: FirTypeOperatorCall, context: CheckerContext, reporter: DiagnosticReporter) { + val targetTypeRef = expression.conversionTypeRef + val declarationToCheck = targetTypeRef.toRegularClassSymbol(context.session) ?: return + + if (!webCheckerUtils.isNativeOrExternalInterface(declarationToCheck, context.session)) { + return + } + + when (expression.operation) { + FirOperation.AS, FirOperation.SAFE_AS -> reporter.reportOn( + expression.source, + FirWebCommonErrors.UNCHECKED_CAST_TO_EXTERNAL_INTERFACE, + expression.argument.resolvedType, + targetTypeRef.coneType, + context, + ) + FirOperation.IS, FirOperation.NOT_IS -> reporter.reportOn( + expression.source, + FirWebCommonErrors.CANNOT_CHECK_FOR_EXTERNAL_INTERFACE, + targetTypeRef.coneType, + context, + ) + else -> {} + } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractReifiedExternalChecker.kt b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractReifiedExternalChecker.kt new file mode 100644 index 00000000000..5481f37dc62 --- /dev/null +++ b/compiler/fir/checkers/checkers.web.common/src/org/jetbrains/kotlin/fir/analysis/web/common/checkers/expression/FirAbstractReifiedExternalChecker.kt @@ -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.analysis.web.common.checkers.expression + +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker +import org.jetbrains.kotlin.fir.analysis.diagnostics.web.common.FirWebCommonErrors +import org.jetbrains.kotlin.fir.analysis.web.common.checkers.FirAbstractWebCheckerUtils +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.expressions.forAllReifiedTypeParameters +import org.jetbrains.kotlin.fir.types.toSymbol + +abstract class FirAbstractReifiedExternalChecker( + private val webCheckerUtils: FirAbstractWebCheckerUtils +) : FirFunctionCallChecker() { + override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) { + expression.forAllReifiedTypeParameters { type, typeArgument -> + val typeSymbol = type.toSymbol(context.session) + if (typeSymbol != null && webCheckerUtils.isNativeOrExternalInterface(typeSymbol, context.session)) { + reporter.reportOn( + typeArgument.source ?: expression.source, + FirWebCommonErrors.EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, + type, + context + ) + } + } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirNonSuppressibleErrorNames.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirNonSuppressibleErrorNames.kt index 33703d8dc99..16718a83e1d 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirNonSuppressibleErrorNames.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirNonSuppressibleErrorNames.kt @@ -628,11 +628,8 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set = setOf( "INLINE_CLASS_IN_EXTERNAL_DECLARATION", "EXTENSION_FUNCTION_IN_EXTERNAL_DECLARATION", "NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE", - "CANNOT_CHECK_FOR_EXTERNAL_INTERFACE", - "EXTERNAL_INTERFACE_AS_CLASS_LITERAL", "JS_EXTERNAL_INHERITORS_ONLY", "JS_EXTERNAL_ARGUMENT", - "EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT", "WRONG_EXPORTED_DECLARATION", "NESTED_JS_EXPORT", "DELEGATION_BY_DYNAMIC", @@ -676,6 +673,9 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set = setOf( "WRONG_BODY_OF_EXTERNAL_DECLARATION", "WRONG_INITIALIZER_OF_EXTERNAL_DECLARATION", "WRONG_DEFAULT_VALUE_FOR_EXTERNAL_FUN_PARAMETER", + "CANNOT_CHECK_FOR_EXTERNAL_INTERFACE", + "EXTERNAL_INTERFACE_AS_CLASS_LITERAL", + "EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT", "JSCODE_ARGUMENT_NON_CONST_EXPRESSION", "SYNTAX", ) diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/castToNativeInterface.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/castToNativeInterface.kt new file mode 100644 index 00000000000..7707d45f168 --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/castToNativeInterface.kt @@ -0,0 +1,8 @@ +// FIR_IDENTICAL +// DIAGNOSTICS: +UNCHECKED_CAST_TO_EXTERNAL_INTERFACE + +external interface I + +fun box(a: Any, b: Any): Pair { + return Pair(a as I, b as? I) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/checkForNativeInterface.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/checkForNativeInterface.kt new file mode 100644 index 00000000000..251f3b8ce95 --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/checkForNativeInterface.kt @@ -0,0 +1,6 @@ +// FIR_IDENTICAL +external interface I + +fun box(a: Any, b: Any): Boolean { + return a is I && b !is I +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceAsReifiedTypeArgument.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceAsReifiedTypeArgument.kt new file mode 100644 index 00000000000..e443b6a194a --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceAsReifiedTypeArgument.kt @@ -0,0 +1,22 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_PARAMETER + +inline fun foo(x: T) { + println(x) +} + +external interface I + +external class C : I + +operator inline fun C.plus(other: T) = this + +fun bar() { + foo(C()) + + val c: I = C() + foo(c) + foo<I>(C()) + + C() + c +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceClassLiteral.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceClassLiteral.kt new file mode 100644 index 00000000000..2a959874af0 --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceClassLiteral.kt @@ -0,0 +1,8 @@ +// FIR_IDENTICAL +external interface I + +typealias TA = I +fun box() { + println(I::class) + println(TA::class) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/whenIsNativeInterface.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/whenIsNativeInterface.kt new file mode 100644 index 00000000000..1433c0838c0 --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/rtti/whenIsNativeInterface.kt @@ -0,0 +1,10 @@ +// FIR_IDENTICAL +external interface I + +external interface J + +fun box(a: Any) = when (a) { + is I -> 0 + !is J -> 1 + else -> 2 +} \ No newline at end of file diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsFirWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsFirWasmTestGenerated.java index b0d76d33354..2ee74d08213 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsFirWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsFirWasmTestGenerated.java @@ -128,6 +128,46 @@ public class DiagnosticsFirWasmTestGenerated extends AbstractDiagnosticsFirWasmT public void testWrongQualifier() throws Exception { runTest("compiler/testData/diagnostics/wasmTests/jsInterop/wrongQualifier.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/wasmTests/jsInterop/rtti") + @TestDataPath("$PROJECT_ROOT") + public class Rtti { + @Test + public void testAllFilesPresentInRtti() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop/rtti"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("castToNativeInterface.kt") + public void testCastToNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/castToNativeInterface.kt"); + } + + @Test + @TestMetadata("checkForNativeInterface.kt") + public void testCheckForNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/checkForNativeInterface.kt"); + } + + @Test + @TestMetadata("nativeInterfaceAsReifiedTypeArgument.kt") + public void testNativeInterfaceAsReifiedTypeArgument() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceAsReifiedTypeArgument.kt"); + } + + @Test + @TestMetadata("nativeInterfaceClassLiteral.kt") + public void testNativeInterfaceClassLiteral() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceClassLiteral.kt"); + } + + @Test + @TestMetadata("whenIsNativeInterface.kt") + public void testWhenIsNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/whenIsNativeInterface.kt"); + } + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java index 424df7dfe06..490ab9ab757 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java @@ -128,6 +128,46 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest { public void testWrongQualifier() throws Exception { runTest("compiler/testData/diagnostics/wasmTests/jsInterop/wrongQualifier.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/wasmTests/jsInterop/rtti") + @TestDataPath("$PROJECT_ROOT") + public class Rtti { + @Test + public void testAllFilesPresentInRtti() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop/rtti"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("castToNativeInterface.kt") + public void testCastToNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/castToNativeInterface.kt"); + } + + @Test + @TestMetadata("checkForNativeInterface.kt") + public void testCheckForNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/checkForNativeInterface.kt"); + } + + @Test + @TestMetadata("nativeInterfaceAsReifiedTypeArgument.kt") + public void testNativeInterfaceAsReifiedTypeArgument() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceAsReifiedTypeArgument.kt"); + } + + @Test + @TestMetadata("nativeInterfaceClassLiteral.kt") + public void testNativeInterfaceClassLiteral() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/nativeInterfaceClassLiteral.kt"); + } + + @Test + @TestMetadata("whenIsNativeInterface.kt") + public void testWhenIsNativeInterface() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/rtti/whenIsNativeInterface.kt"); + } + } } @Nested