[Wasm] Port JS interop type checker to K2 (KT-56849)

This commit is contained in:
Svyatoslav Kuzmich
2023-10-31 12:34:32 +00:00
committed by Space Team
parent 0c46cfd761
commit 15d3bf5e25
12 changed files with 306 additions and 27 deletions
@@ -9,7 +9,7 @@ fun funBlockBody(x: Int): Int {
}
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>returnTypeNotSepcified<!>() = js("1")
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>valTypeNotSepcified<!> = js("1")
<!WRONG_JS_INTEROP_TYPE!>val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>valTypeNotSepcified<!><!> = js("1")
val a = "1"
fun nonConst(): String = "1"
@@ -67,45 +67,50 @@ external fun <
T3 : T1?
> supportedTypeParamtersUpperBounds(p1: T1, p2: T2): T3
external fun supportedVararg(vararg p: Int)
external fun wrongExternalTypes(
any: Any,
nany: Any?,
unit: Unit,
nunit: Unit?,
nothing: Nothing,
nnothing: Nothing?,
charSequence: CharSequence,
list: List<Int>,
array: Array<Int>,
intArray: IntArray,
pair: Pair<Int, Int>,
number: Number,
<!WRONG_JS_INTEROP_TYPE!>any: Any<!>,
<!WRONG_JS_INTEROP_TYPE!>nany: Any?<!>,
<!WRONG_JS_INTEROP_TYPE!>unit: Unit<!>,
<!WRONG_JS_INTEROP_TYPE!>nunit: Unit?<!>,
<!WRONG_JS_INTEROP_TYPE!>nothing: Nothing<!>,
<!WRONG_JS_INTEROP_TYPE!>nnothing: Nothing?<!>,
<!WRONG_JS_INTEROP_TYPE!>charSequence: CharSequence<!>,
<!WRONG_JS_INTEROP_TYPE!>list: List<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>array: Array<Int><!>,
<!WRONG_JS_INTEROP_TYPE!>intArray: IntArray<!>,
<!WRONG_JS_INTEROP_TYPE!>pair: Pair<Int, Int><!>,
<!WRONG_JS_INTEROP_TYPE!>number: Number<!>,
)
external fun <T> supportedTypeParamtersUpperBounds(p: T): T where T : EI, T : Any
external fun wrongVararg(<!WRONG_JS_INTEROP_TYPE!>vararg p: Any<!>)
external fun <T> supportedTypeParamtersUpperBounds(p: T): T where T : EI, T : <!WRONG_JS_INTEROP_TYPE!>Any<!>
external fun <
T1,
T2 : Number,
T3: List<Int>,
<!WRONG_JS_INTEROP_TYPE!>T1<!>,
T2 : <!WRONG_JS_INTEROP_TYPE!>Number<!>,
T3: <!WRONG_JS_INTEROP_TYPE!>List<Int><!>,
> supportedTypeParamtersUpperBounds(
p1: T1,
p2: T2
): T3
fun jsCode1(x: Any): Any = js("x")
fun jsCode2(x: Any): Any {
<!WRONG_JS_INTEROP_TYPE!>fun jsCode1(<!WRONG_JS_INTEROP_TYPE!>x: Any<!>): Any<!> = js("x")
<!WRONG_JS_INTEROP_TYPE!>fun jsCode2(<!WRONG_JS_INTEROP_TYPE!>x: Any<!>): Any<!> {
js("return x;")
}
val jsProp: Any = js("1")
<!WRONG_JS_INTEROP_TYPE!>val jsProp: Any<!> = js("1")
@JsExport
fun exported(x: Any): Any = x
<!WRONG_JS_INTEROP_TYPE!>@JsExport
fun exported(<!WRONG_JS_INTEROP_TYPE!>x: Any<!>): Any<!> = x
typealias EI_alias = EI
typealias Any_alias = Any
typealias Function_alias = (Int) -> Int
external fun fooAlias(
ei: EI_alias,
any: Any_alias,
<!WRONG_JS_INTEROP_TYPE!>any: Any_alias<!>,
function: Function_alias,
)
@@ -67,6 +67,7 @@ external fun <
T3 : T1?
> supportedTypeParamtersUpperBounds(p1: T1, p2: T2): T3
external fun supportedVararg(vararg p: Int)
external fun wrongExternalTypes(
<!WRONG_JS_INTEROP_TYPE!>any: Any<!>,
@@ -83,6 +84,8 @@ external fun wrongExternalTypes(
<!WRONG_JS_INTEROP_TYPE!>number: Number<!>,
)
external fun wrongVararg(<!WRONG_JS_INTEROP_TYPE!>vararg p: Any<!>)
external fun <<!WRONG_JS_INTEROP_TYPE!>T<!>> supportedTypeParamtersUpperBounds(p: T): T where T : EI, T : Any
external fun <
@@ -105,7 +108,9 @@ fun exported(<!WRONG_JS_INTEROP_TYPE!>x: Any<!>): Any<!> = x
typealias EI_alias = EI
typealias Any_alias = Any
typealias Function_alias = (Int) -> Int
external fun fooAlias(
ei: EI_alias,
<!WRONG_JS_INTEROP_TYPE!>any: Any_alias<!>,
function: Function_alias,
)