[FIR][checkers][Wasm] Refine WRONG_JS_INTEROP_TYPE reporting

This commit improves four aspects of WRONG_JS_INTEROP_TYPE error reporting:
1) more precise source code ranges are preferred when possible (e.g. value parameter type instead of the entire value parameter, explicit return type instead of the entire declaration, etc.)
2) only relevant parameter and return types of function types are reported as wrong (to prevent confusion with the "function types are supported" part of the error message)
3) WRONG_JS_INTEROP_TYPE errors are now deduplicated in cases where more than one such error was previously reported because of compiler-generated declarations
4) error messages were slightly proofread and contain slightly more information now
This commit is contained in:
Stanislav Ruban
2024-03-11 00:00:15 +02:00
committed by Space Team
parent a65ea2ce02
commit 4dd0a25eca
4 changed files with 193 additions and 215 deletions
@@ -57,7 +57,7 @@ object FirWasmErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION, "This property can only be used from external declarations.")
map.put(
WRONG_JS_INTEROP_TYPE,
"Type ''{0}'' cannot be used in {1}. Only external, primitive, string and function types are supported in Kotlin/Wasm JS interop.",
"Type ''{0}'' cannot be used as {1}. Only external, primitive, string, and function types are supported in Kotlin/Wasm JS interop.",
FirDiagnosticRenderers.RENDER_TYPE, TO_STRING
)
map.put(
@@ -5,10 +5,11 @@
package org.jetbrains.kotlin.fir.analysis.wasm.checkers.declaration
import org.jetbrains.kotlin.KtFakeSourceElement
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirFunctionTypeParameter
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
@@ -17,7 +18,6 @@ import org.jetbrains.kotlin.fir.analysis.wasm.checkers.hasValidJsCodeBody
import org.jetbrains.kotlin.fir.analysis.wasm.checkers.isJsExportedDeclaration
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.isEffectivelyExternal
import org.jetbrains.kotlin.fir.declarations.utils.isEnumClass
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.WasmStandardClassIds
@@ -46,114 +46,92 @@ object FirWasmJsInteropTypesChecker : FirBasicDeclarationChecker(MppCheckerKind.
return
}
// Skip enums to avoid reporting errors for synthetic static members with unsupported interop types.
// External enums errors are reported in a separate checker.
if (context.containingDeclarations.any { it is FirClass && it.isEnumClass }) {
return
// filter out compiler-generated declarations (data/enum methods, property accessors, primary constructors, etc.) to prevent
// 1) reporting excessive diagnostics
// (e.g. on generated methods of external enum classes (which are handled by another checker))
// 2) reporting duplicate diagnostics
// (e.g. on properties with generated accessors and type parameters of classes with generated primary constructors)
if (declaration.source is KtFakeSourceElement) return
fun ConeKotlinType.isSupportedInJsInterop(position: Position): Boolean {
if (isUnit || isNothing) {
// Unit and Nothing are supported in return type positions and unsupported in other type positions
return position == Position.RETURN_TYPE || position == Position.FUNCTION_TYPE_RETURN_TYPE
}
// primitive types, unsigned types, and String are supported (regardless of nullability)
if (isPrimitiveOrNullablePrimitive) return true
if (isUnsignedTypeOrNullableUnsignedType) return true
if (isString || isNullableString) return true
// type parameters' upper bounds should be checked separately on declaration-site
if (this is ConeTypeParameterType) return true
// function types themselves are supported
// (and their parameter and return types should be checked separately)
if (isBasicFunctionType(session)) return true
// aside from the aforementioned cases, only external types are supported
return toRegularClassSymbol(session)?.isEffectivelyExternal(session) == true
}
fun ConeKotlinType.checkJsInteropType(
typePositionDescription: String,
source: KtSourceElement?,
isInFunctionReturnPosition: Boolean = false,
) {
if (!isTypeSupportedInJsInterop(this, isInFunctionReturnPosition, session)) {
fun FirTypeRef.checkSupportInJsInterop(position: Position, fallbackSource: KtSourceElement?) {
val type = coneType.let {
val unexpandedType = if (position == Position.VARARG_VALUE_PARAMETER_TYPE) it.varargElementType() else it
unexpandedType.fullyExpandedType(session)
}
if (!type.isSupportedInJsInterop(position)) {
reporter.reportOn(
source,
source ?: fallbackSource,
FirWasmErrors.WRONG_JS_INTEROP_TYPE,
this,
typePositionDescription,
type,
position.description,
context
)
return
}
// although function types themselves are supported, their parameter and return types should be checked separately
val functionTypeRef = (this as? FirResolvedTypeRef)?.delegatedTypeRef as? FirFunctionTypeRef ?: return
with(functionTypeRef) {
parameters.map(FirFunctionTypeParameter::returnTypeRef).forEach { parameterTypeRef ->
parameterTypeRef.checkSupportInJsInterop(Position.FUNCTION_TYPE_PARAMETER_TYPE, fallbackSource = functionTypeRef.source)
}
returnTypeRef.checkSupportInJsInterop(Position.FUNCTION_TYPE_RETURN_TYPE, fallbackSource = functionTypeRef.source)
}
}
fun FirTypeParameterRef.checkJsInteropTypeParameter() {
for (upperBound in this.symbol.resolvedBounds) {
upperBound.type.checkJsInteropType(
"JS interop type parameter upper bound",
upperBound.source ?: this.source
)
}
}
if (declaration is FirMemberDeclaration) {
if (declaration is FirTypeParameterRefsOwner) {
for (typeParameter in declaration.typeParameters) {
typeParameter.checkJsInteropTypeParameter()
for (upperBound in typeParameter.symbol.resolvedBounds) {
upperBound.checkSupportInJsInterop(Position.TYPE_PARAMETER_UPPER_BOUND, fallbackSource = typeParameter.source)
}
}
}
when (declaration) {
is FirProperty -> {
declaration.returnTypeRef.coneType.checkJsInteropType(
"JS interop property",
declaration.source
)
declaration.returnTypeRef.checkSupportInJsInterop(Position.PROPERTY_TYPE, fallbackSource = declaration.source)
}
is FirFunction -> {
for (parameter in declaration.valueParameters) {
val type = parameter.returnTypeRef.coneType
val varargElementTypeOrType = if (parameter.isVararg) type.varargElementType() else type
varargElementTypeOrType.checkJsInteropType(
"JS interop function parameter",
parameter.source
)
for (valueParameter in declaration.valueParameters) {
val position = if (valueParameter.isVararg) Position.VARARG_VALUE_PARAMETER_TYPE else Position.VALUE_PARAMETER_TYPE
valueParameter.returnTypeRef.checkSupportInJsInterop(position, fallbackSource = valueParameter.source)
}
declaration.returnTypeRef.coneType.checkJsInteropType(
"JS interop function return",
declaration.source,
isInFunctionReturnPosition = true
)
declaration.returnTypeRef.checkSupportInJsInterop(Position.RETURN_TYPE, fallbackSource = declaration.source)
}
else -> {}
else -> Unit
}
}
}
private fun isTypeSupportedInJsInterop(
unexpandedType: ConeKotlinType,
isInFunctionReturnPosition: Boolean,
session: FirSession,
): Boolean {
val type = unexpandedType.fullyExpandedType(session)
if (type.isUnit || type.isNothing) {
return isInFunctionReturnPosition
}
val nonNullable = type.withNullability(ConeNullability.NOT_NULL, session.typeContext)
if (nonNullable.isPrimitive || nonNullable.isUnsignedType || nonNullable.isString) {
return true
}
// Interop type parameters upper bounds should be checked
// on declaration site separately
if (nonNullable is ConeTypeParameterType) {
return true
}
val regularClassSymbol = nonNullable.toRegularClassSymbol(session)
if (regularClassSymbol?.isEffectivelyExternal(session) == true) {
return true
}
if (type.isBasicFunctionType(session)) {
val arguments = type.typeArguments
for (i in 0 until arguments.lastIndex) {
val argType = arguments[i].type ?: return false
if (!isTypeSupportedInJsInterop(argType, isInFunctionReturnPosition = false, session)) {
return false
}
}
val returnType = arguments.last().type ?: return false
return isTypeSupportedInJsInterop(
returnType,
isInFunctionReturnPosition = true,
session
)
}
return false
private enum class Position(val description: String) {
TYPE_PARAMETER_UPPER_BOUND("upper bound of JS interop type parameter"),
PROPERTY_TYPE("type of JS interop property"),
VALUE_PARAMETER_TYPE("value parameter type of JS interop function"),
VARARG_VALUE_PARAMETER_TYPE("value parameter type of JS interop function"),
RETURN_TYPE("return type of JS interop function"),
FUNCTION_TYPE_PARAMETER_TYPE("parameter type of JS interop function type"),
FUNCTION_TYPE_RETURN_TYPE("return type of JS interop function type"),
}
}
@@ -17,12 +17,12 @@ external fun complexFunctionTypesWithNullableTypes(
)
external fun complexFunctionTypesWithWrongTypes(
<!WRONG_JS_INTEROP_TYPE!>f1: ((Any?, Byte?, Unit?, Int?, CharSequence?, Float?, IntArray?, Char?, String?, EI?, EC?, EO?) -> Unit)?<!>,
<!WRONG_JS_INTEROP_TYPE!>f2: ((Boolean?) -> ((Any?) -> ((Float?) -> ((CharSequence?) -> EI)?)?)?)?<!>,
<!WRONG_JS_INTEROP_TYPE!>f3: ((((((((Boolean?) -> Unit?)?) -> Float?)?) -> IntArray?)?) -> EI?)?<!>,
f1: ((<!WRONG_JS_INTEROP_TYPE!>Any?<!>, Byte?, <!WRONG_JS_INTEROP_TYPE!>Unit?<!>, Int?, <!WRONG_JS_INTEROP_TYPE!>CharSequence?<!>, Float?, <!WRONG_JS_INTEROP_TYPE!>IntArray?<!>, Char?, String?, EI?, EC?, EO?) -> Unit)?,
f2: ((Boolean?) -> ((<!WRONG_JS_INTEROP_TYPE!>Any?<!>) -> ((Float?) -> ((<!WRONG_JS_INTEROP_TYPE!>CharSequence?<!>) -> EI)?)?)?)?,
f3: ((((((((Boolean?) -> <!WRONG_JS_INTEROP_TYPE!>Unit?<!>)?) -> Float?)?) -> <!WRONG_JS_INTEROP_TYPE!>IntArray?<!>)?) -> EI?)?,
)
external fun <T> typeParameterWithUpperBoundsWithDifferentJsInteropCorrectness(arg: T): T where T : EI, T : <!WRONG_JS_INTEROP_TYPE!>Any<!>
<!WRONG_JS_INTEROP_TYPE!>fun jsCodeFunctionWithBlockBody(<!WRONG_JS_INTEROP_TYPE!>x: Any<!>): Any<!> { js("return x;") }
<!WRONG_JS_INTEROP_TYPE!>val jsCodeProperty: Any<!> = js("1")
fun jsCodeFunctionWithBlockBody(x: <!WRONG_JS_INTEROP_TYPE!>Any<!>): <!WRONG_JS_INTEROP_TYPE!>Any<!> { js("return x;") }
val jsCodeProperty: <!WRONG_JS_INTEROP_TYPE!>Any<!> = js("1")
@@ -9,76 +9,76 @@ object UserDefinedObject
external fun wrongJsInteropTypes(
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>unit: Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: Nothing<!>,
unit: <!WRONG_JS_INTEROP_TYPE!>Unit<!>,
nothing: <!WRONG_JS_INTEROP_TYPE!>Nothing<!>,
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: Any<!>,
<!WRONG_JS_INTEROP_TYPE!>number: Number<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: CharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: IntArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: Pair<Int, Int><!>,
<!WRONG_JS_INTEROP_TYPE!>list: List<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: Array<Int><!>,
any: <!WRONG_JS_INTEROP_TYPE!>Any<!>,
number: <!WRONG_JS_INTEROP_TYPE!>Number<!>,
charSequence: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
specializedArray: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>,
pair: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
list: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
genericArray: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: UserDefinedInterface<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: UserDefinedOpenClass<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: UserDefinedObject<!>,
userDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
userDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
userDefinedObject: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
)
external fun wrongNullableJsInteropTypes(
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>unit: Unit?<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: Nothing?<!>,
unit: <!WRONG_JS_INTEROP_TYPE!>Unit?<!>,
nothing: <!WRONG_JS_INTEROP_TYPE!>Nothing?<!>,
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: Any?<!>,
<!WRONG_JS_INTEROP_TYPE!>number: Number?<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: CharSequence?<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: IntArray?<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: Pair<Int, Int>?<!>,
<!WRONG_JS_INTEROP_TYPE!>list: List<Int>?<!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: Array<Int>?<!>,
any: <!WRONG_JS_INTEROP_TYPE!>Any?<!>,
number: <!WRONG_JS_INTEROP_TYPE!>Number?<!>,
charSequence: <!WRONG_JS_INTEROP_TYPE!>CharSequence?<!>,
specializedArray: <!WRONG_JS_INTEROP_TYPE!>IntArray?<!>,
pair: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int>?<!>,
list: <!WRONG_JS_INTEROP_TYPE!>List<Int>?<!>,
genericArray: <!WRONG_JS_INTEROP_TYPE!>Array<Int>?<!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: UserDefinedInterface?<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: UserDefinedOpenClass?<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: UserDefinedObject?<!>,
userDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface?<!>,
userDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass?<!>,
userDefinedObject: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject?<!>,
)
// wrong JS interop types as return types
// built-in types
<!WRONG_JS_INTEROP_TYPE!>external fun anyAsReturnType(): Any<!>
<!WRONG_JS_INTEROP_TYPE!>external fun numberAsReturnType(): Number<!>
<!WRONG_JS_INTEROP_TYPE!>external fun charSequenceAsReturnType(): CharSequence<!>
<!WRONG_JS_INTEROP_TYPE!>external fun specializedArrayAsReturnType(): IntArray<!>
<!WRONG_JS_INTEROP_TYPE!>external fun pairAsReturnType(): Pair<Int, Int><!>
<!WRONG_JS_INTEROP_TYPE!>external fun listAsReturnType(): List<Int><!>
<!WRONG_JS_INTEROP_TYPE!>external fun genericArrayAsReturnType(): Array<Int><!>
external fun anyAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>Any<!>
external fun numberAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>Number<!>
external fun charSequenceAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>
external fun specializedArrayAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>IntArray<!>
external fun pairAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>
external fun listAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>List<Int><!>
external fun genericArrayAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>external fun userDefinedInterfaceAsReturnType(): UserDefinedInterface<!>
<!WRONG_JS_INTEROP_TYPE!>external fun userDefinedOpenClassAsReturnType(): UserDefinedOpenClass<!>
<!WRONG_JS_INTEROP_TYPE!>external fun userDefinedObjectAsReturnType(): UserDefinedObject<!>
external fun userDefinedInterfaceAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>
external fun userDefinedOpenClassAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>
external fun userDefinedObjectAsReturnType(): <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>
// wrong JS interop types as vararg parameter types
// Unit (Nothing is not allowed in vararg parameters)
external fun unitAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: Unit<!>)
external fun unitAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>Unit<!>)
// built-in types
external fun anyAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: Any<!>)
external fun numberAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: Number<!>)
external fun charSequenceAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: CharSequence<!>)
external fun specializedArrayAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: IntArray<!>)
external fun pairAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: Pair<Int, Int><!>)
external fun listAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: List<Int><!>)
external fun genericArrayAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: Array<Int><!>)
external fun anyAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>Any<!>)
external fun numberAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>Number<!>)
external fun charSequenceAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>)
external fun specializedArrayAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>)
external fun pairAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>)
external fun listAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>)
external fun genericArrayAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>)
// user-defined types
external fun userDefinedInterfaceAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: UserDefinedInterface<!>)
external fun userDefinedOpenClassAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: UserDefinedOpenClass<!>)
external fun userDefinedObjectAsVarargParameterType(<!WRONG_JS_INTEROP_TYPE!>vararg args: UserDefinedObject<!>)
external fun userDefinedInterfaceAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>)
external fun userDefinedOpenClassAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>)
external fun userDefinedObjectAsVarargParameterType(vararg args: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>)
external fun <
@@ -115,101 +115,101 @@ external fun <
external class WrongJsInteropTypesAsClassTypeParameterUpperBounds<
// Unit (Nothing as an upper bound results in an empty intersection type)
TUnit: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>Unit<!>,
TUnit: <!WRONG_JS_INTEROP_TYPE!>Unit<!>,
// built-in types
TAny: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>Any<!>,
TNumber: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>Number<!>,
TCharSequence: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
TSpecializedArray: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>IntArray<!>,
TPair: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
TList: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>List<Int><!>,
TGenericArray: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
TAny: <!WRONG_JS_INTEROP_TYPE!>Any<!>,
TNumber: <!WRONG_JS_INTEROP_TYPE!>Number<!>,
TCharSequence: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
TSpecializedArray: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>,
TPair: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
TList: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
TGenericArray: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
// user-defined types
TUserDefinedInterface: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
TUserDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
TUserDefinedObject: <!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
TUserDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
TUserDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
TUserDefinedObject: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
// type parameter with implicit upper bound
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>TTypeParameterWithImplicitUpperBound<!>
<!WRONG_JS_INTEROP_TYPE!>TTypeParameterWithImplicitUpperBound<!>
>
// wrong JS interop types as property types
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>external val unitProperty: Unit<!>
<!WRONG_JS_INTEROP_TYPE!>external val nothingProperty: Nothing<!>
external val unitProperty: <!WRONG_JS_INTEROP_TYPE!>Unit<!>
external val nothingProperty: <!WRONG_JS_INTEROP_TYPE!>Nothing<!>
// built-in types
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val anyProperty: Any<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val numberProperty: Number<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val charSequenceProperty: CharSequence<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val specializedArrayProperty: IntArray<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val pairProperty: Pair<Int, Int><!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val listProperty: List<Int><!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val genericArrayProperty: Array<Int><!>
external val anyProperty: <!WRONG_JS_INTEROP_TYPE!>Any<!>
external val numberProperty: <!WRONG_JS_INTEROP_TYPE!>Number<!>
external val charSequenceProperty: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>
external val specializedArrayProperty: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>
external val pairProperty: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>
external val listProperty: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>
external val genericArrayProperty: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>
// user-defined types
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val userDefinedInterfaceProperty: UserDefinedInterface<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val userDefinedOpenClassProperty: UserDefinedOpenClass<!>
<!WRONG_JS_INTEROP_TYPE, WRONG_JS_INTEROP_TYPE!>external val userDefinedObjectProperty: UserDefinedObject<!>
external val userDefinedInterfaceProperty: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>
external val userDefinedOpenClassProperty: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>
external val userDefinedObjectProperty: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>
external fun wrongJsInteropTypesAsFunctionTypeParameterTypes(
<!WRONG_JS_INTEROP_TYPE!>unitAndNothing: (Unit, Nothing) -> Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>builtInTypes: (Any, Number, CharSequence, IntArray, Pair<Int, Int>, List<Int>, Array<Int>) -> Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedTypes: (UserDefinedInterface, UserDefinedOpenClass, UserDefinedObject) -> Unit<!>,
unitAndNothing: (<!WRONG_JS_INTEROP_TYPE!>Unit<!>, <!WRONG_JS_INTEROP_TYPE!>Nothing<!>) -> Unit,
builtInTypes: (<!WRONG_JS_INTEROP_TYPE!>Any<!>, <!WRONG_JS_INTEROP_TYPE!>Number<!>, <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>, <!WRONG_JS_INTEROP_TYPE!>IntArray<!>, <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>, <!WRONG_JS_INTEROP_TYPE!>List<Int><!>, <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>) -> Unit,
userDefinedTypes: (<!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>, <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>, <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>) -> Unit,
)
external fun wrongJsInteropTypesAsFunctionTypeReturnTypes(
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: () -> Any<!>,
<!WRONG_JS_INTEROP_TYPE!>number: () -> Number<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: () -> CharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: () -> IntArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: () -> Pair<Int, Int><!>,
<!WRONG_JS_INTEROP_TYPE!>list: () -> List<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: () -> Array<Int><!>,
any: () -> <!WRONG_JS_INTEROP_TYPE!>Any<!>,
number: () -> <!WRONG_JS_INTEROP_TYPE!>Number<!>,
charSequence: () -> <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
specializedArray: () -> <!WRONG_JS_INTEROP_TYPE!>IntArray<!>,
pair: () -> <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
list: () -> <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
genericArray: () -> <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: () -> UserDefinedInterface<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: () -> UserDefinedOpenClass<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: () -> UserDefinedObject<!>,
userDefinedInterface: () -> <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
userDefinedOpenClass: () -> <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
userDefinedObject: () -> <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
)
fun wrongJsInteropTypesInJsCodeFunction(
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>unit: Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: Nothing<!>,
unit: <!WRONG_JS_INTEROP_TYPE!>Unit<!>,
nothing: <!WRONG_JS_INTEROP_TYPE!>Nothing<!>,
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: Any<!>,
<!WRONG_JS_INTEROP_TYPE!>number: Number<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: CharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: IntArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: Pair<Int, Int><!>,
<!WRONG_JS_INTEROP_TYPE!>list: List<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: Array<Int><!>,
any: <!WRONG_JS_INTEROP_TYPE!>Any<!>,
number: <!WRONG_JS_INTEROP_TYPE!>Number<!>,
charSequence: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
specializedArray: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>,
pair: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
list: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
genericArray: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: UserDefinedInterface<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: UserDefinedOpenClass<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: UserDefinedObject<!>,
userDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
userDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
userDefinedObject: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
): Nothing = js("42")
@JsExport
fun wrongJsInteropTypesInJsExportFunction(
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>unit: Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: Nothing<!>,
unit: <!WRONG_JS_INTEROP_TYPE!>Unit<!>,
nothing: <!WRONG_JS_INTEROP_TYPE!>Nothing<!>,
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: Any<!>,
<!WRONG_JS_INTEROP_TYPE!>number: Number<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: CharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: IntArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: Pair<Int, Int><!>,
<!WRONG_JS_INTEROP_TYPE!>list: List<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: Array<Int><!>,
any: <!WRONG_JS_INTEROP_TYPE!>Any<!>,
number: <!WRONG_JS_INTEROP_TYPE!>Number<!>,
charSequence: <!WRONG_JS_INTEROP_TYPE!>CharSequence<!>,
specializedArray: <!WRONG_JS_INTEROP_TYPE!>IntArray<!>,
pair: <!WRONG_JS_INTEROP_TYPE!>Pair<Int, Int><!>,
list: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
genericArray: <!WRONG_JS_INTEROP_TYPE!>Array<Int><!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: UserDefinedInterface<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: UserDefinedOpenClass<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: UserDefinedObject<!>,
userDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>UserDefinedInterface<!>,
userDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>UserDefinedOpenClass<!>,
userDefinedObject: <!WRONG_JS_INTEROP_TYPE!>UserDefinedObject<!>,
) {}
@@ -230,18 +230,18 @@ typealias AliasedUserDefinedObject = UserDefinedObject
external fun aliasedWrongJsInteropTypes(
// Unit and Nothing
<!WRONG_JS_INTEROP_TYPE!>unit: AliasedUnit<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: AliasedNothing<!>,
unit: <!WRONG_JS_INTEROP_TYPE!>AliasedUnit<!>,
nothing: <!WRONG_JS_INTEROP_TYPE!>AliasedNothing<!>,
// built-in types
<!WRONG_JS_INTEROP_TYPE!>any: AliasedAny<!>,
<!WRONG_JS_INTEROP_TYPE!>number: AliasedNumber<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: AliasedCharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>specializedArray: AliasedSpecializedArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: AliasedPair<!>,
<!WRONG_JS_INTEROP_TYPE!>list: AliasedList<!>,
<!WRONG_JS_INTEROP_TYPE!>genericArray: AliasedGenericArray<!>,
any: <!WRONG_JS_INTEROP_TYPE!>AliasedAny<!>,
number: <!WRONG_JS_INTEROP_TYPE!>AliasedNumber<!>,
charSequence: <!WRONG_JS_INTEROP_TYPE!>AliasedCharSequence<!>,
specializedArray: <!WRONG_JS_INTEROP_TYPE!>AliasedSpecializedArray<!>,
pair: <!WRONG_JS_INTEROP_TYPE!>AliasedPair<!>,
list: <!WRONG_JS_INTEROP_TYPE!>AliasedList<!>,
genericArray: <!WRONG_JS_INTEROP_TYPE!>AliasedGenericArray<!>,
// user-defined types
<!WRONG_JS_INTEROP_TYPE!>userDefinedInterface: AliasedUserDefinedInterface<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedOpenClass: AliasedUserDefinedOpenClass<!>,
<!WRONG_JS_INTEROP_TYPE!>userDefinedObject: AliasedUserDefinedObject<!>,
userDefinedInterface: <!WRONG_JS_INTEROP_TYPE!>AliasedUserDefinedInterface<!>,
userDefinedOpenClass: <!WRONG_JS_INTEROP_TYPE!>AliasedUserDefinedOpenClass<!>,
userDefinedObject: <!WRONG_JS_INTEROP_TYPE!>AliasedUserDefinedObject<!>,
)