[FIR JS] Prepare the test data for FIR

This commit is contained in:
Nikolay Lunyak
2023-01-03 13:24:08 +02:00
committed by Space Team
parent 0e38d0ebd2
commit 73c89a5d9d
181 changed files with 3790 additions and 10 deletions
@@ -0,0 +1,5 @@
external class A {
init {
definedExternally
}
}
@@ -0,0 +1,30 @@
external fun foo(): Int = definedExternally
external fun bar(): Unit {
definedExternally
}
external fun baz(): Int = 23
external fun f(x: Int, y: String = definedExternally): Unit
external fun g(x: Int, y: String = ""): Unit
external var a: Int
get() = definedExternally
set(value) {
definedExternally
}
external val b: Int
get() = 23
external val c: Int = definedExternally
external val d: Int = 23
external class C {
fun foo(): Int = definedExternally
fun bar(): Int = 23
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -DEBUG_INFO_MISSING_UNRESOLVED
external open class Base(x: Int) {
constructor(x: String) : this(23)
constructor(x: String, y: String) : this("")
}
external open class Derived1() : Base(23) {
constructor(x: Byte) : super(23)
constructor(x: String) : super("")
constructor(x: String, y: String) : super("")
}
external open class Derived2() : Base("")
@@ -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 : I by O {
val prop by Delegate()
var mutableProp by Delegate()
}
external val topLevelProp by Delegate()
@@ -0,0 +1,7 @@
external enum class E {
X,
Y {
fun foo()
},
Z {}
}
@@ -0,0 +1,10 @@
class A
external fun A.foo(): Unit = definedExternally
external var A.bar: String
get() = definedExternally
set(value) = definedExternally
external val A.baz: String
get() = definedExternally
@@ -0,0 +1,25 @@
external fun foo(f: Int.() -> Int)
external fun bar(vararg f: Int.() -> Int)
external fun baz(): Int.() -> Int
external val prop: Int.() -> Int
external var prop2: Int.() -> Int
external val propGet
get(): Int.() -> Int = definedExternally
external var propSet
get(): Int.() -> Int = definedExternally
set(v: Int.() -> Int) = definedExternally
external class A(f: Int.() -> Int)
external data class B(
val a: Int.() -> Int,
var b: Int.() -> Int
) {
val c: Int.() -> Int
}
@@ -0,0 +1,3 @@
external fun interface I {
fun f()
}
@@ -0,0 +1,11 @@
external interface I {
interface J
class C
object O
enum class E
companion object
}
@@ -0,0 +1,19 @@
open class A
interface I
external open class B
external class C : A
external class D : B, I
external interface K : I
external enum class E {
X
}
external enum class F : I {
X
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -NOTHING_TO_INLINE
inline external fun foo(): Unit
inline external val bar: Int
get() = definedExternally
external val baz: Int
inline get() = definedExternally
external class A {
inline fun foo(): Unit
inline val bar: Int
get() = definedExternally
val baz: Int
inline get() = definedExternally
}
@@ -0,0 +1,9 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
external inline class C(val a: Int) {
fun foo()
}
<!WRONG_MODIFIER_TARGET!>inline<!> external enum class E {
A
}
@@ -0,0 +1,64 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
// FILE: uint.kt
package kotlin
inline class UInt(private val i: Int)
// FILE: test.kt
inline class SomeIC(val a: Int)
external val l: SomeIC
external val ll
get(): SomeIC = definedExternally
external var r: SomeIC
external var rr: SomeIC
get() = definedExternally
set(v: SomeIC) { definedExternally }
external fun foo(): SomeIC
external fun foo(c: SomeIC): SomeIC
external fun foo(a: Int, c: SomeIC): SomeIC
external fun foo(a: Int, <!FORBIDDEN_VARARG_PARAMETER_TYPE!>vararg<!> args: SomeIC)
external fun foo(a: Int, ui: UInt, vararg args: UInt)
external class CC(
a: SomeIC,
val b: SomeIC,
var c: SomeIC
) {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
class N(
a: SomeIC,
val b: SomeIC,
var c: SomeIC
) {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
}
}
external interface EI {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
}
@@ -0,0 +1,65 @@
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses, +JsAllowValueClassesInExternals
// !DIAGNOSTICS: +INLINE_CLASS_IN_EXTERNAL_DECLARATION_WARNING
// FILE: uint.kt
package kotlin
inline class UInt(private val i: Int)
// FILE: test.kt
inline class SomeIC(val a: Int)
external val l: SomeIC
external val ll
get(): SomeIC = definedExternally
external var r: SomeIC
external var rr: SomeIC
get() = definedExternally
set(v: SomeIC) { definedExternally }
external fun foo(): SomeIC
external fun foo(c: SomeIC): SomeIC
external fun foo(a: Int, c: SomeIC): SomeIC
external fun foo(a: Int, <!FORBIDDEN_VARARG_PARAMETER_TYPE!>vararg<!> args: SomeIC)
external fun foo(a: Int, ui: UInt, vararg args: UInt)
external class CC(
a: SomeIC,
val b: SomeIC,
var c: SomeIC
) {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
class N(
a: SomeIC,
val b: SomeIC,
var c: SomeIC
) {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
}
}
external interface EI {
val l: SomeIC
var r: SomeIC
fun foo(): SomeIC
fun foo(c: SomeIC): SomeIC
fun foo(a: Int, c: SomeIC): SomeIC
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
external class A {
class B
}
@@ -0,0 +1,9 @@
external class C {
inner class Inner
}
external enum class E {
X;
inner class Inner
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
fun foo() {
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
@nativeGetter
fun Int.get(a: Any): Int? = 1
@nativeGetter
fun Int.get2(): String? = "OK"
@nativeGetter
fun Int.get3(a: Any, b: Int, c: Any?): String? = "OK"
@nativeGetter
fun Any.foo(a: Int = 1): Any? = "OK"
}
@@ -0,0 +1,45 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
class A {
@nativeGetter
fun get(a: String): Any? = null
@nativeGetter
fun take(a: Number): String? = null
@nativeGetter
fun foo(a: Double): String? = null
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo = 0
}
class C {
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
@nativeGetter
fun get(): Any? = null
@nativeGetter
fun get(a: A): Any? = null
@nativeGetter
fun foo(a: Int) {}
@nativeGetter
fun bar(a: String): Int = 0
@nativeGetter
fun baz(a: Int = 0): Int? = 0
}
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
@nativeGetter
fun toplevelFun(): Any = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
class Foo {}
}
@@ -0,0 +1,57 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
@nativeGetter
fun get(a: String): Any? = definedExternally
@nativeGetter
fun take(a: Number): String? = definedExternally
@nativeGetter
fun foo(a: Double): String? = definedExternally
companion object {
@nativeGetter
fun get(a: String): Any? = definedExternally
@nativeGetter
fun take(a: Number): String? = definedExternally
@nativeGetter
fun foo(a: Double): String? = definedExternally
}
}
external class B {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj2 {}
}
}
external class C {
@nativeGetter
fun get(): Any? = definedExternally
@nativeGetter
fun get(a: A): Any? = definedExternally
@nativeGetter
fun foo(a: Int) { definedExternally }
@nativeGetter
fun bar(a: String): Int = definedExternally
@nativeGetter
fun baz(a: String = definedExternally): Int? = definedExternally
}
@@ -0,0 +1,77 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
class B {
class A {
@nativeGetter
fun get(a: String): Any? = definedExternally
@nativeGetter
fun take(a: Number): String? = definedExternally
@nativeGetter
fun foo(a: Double): String? = definedExternally
companion object {
@nativeGetter
fun get(a: String): Any? = definedExternally
@nativeGetter
fun take(a: Number): String? = definedExternally
@nativeGetter
fun foo(a: Double): String? = definedExternally
}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj2 {}
}
}
class C {
@nativeGetter
fun get(): Any? = definedExternally
@nativeGetter
fun get(a: A): Any? = definedExternally
@nativeGetter
fun foo(a: Int) { definedExternally }
@nativeGetter
fun bar(a: String): Int = definedExternally
@nativeGetter
fun baz(a: Number = definedExternally): Int? = definedExternally
}
object obj {
@nativeGetter
fun get(): Any? = definedExternally
@nativeGetter
fun get(a: A): Any? = definedExternally
@nativeGetter
fun foo(a: Int) { definedExternally }
@nativeGetter
fun bar(a: String): Int = definedExternally
@nativeGetter
fun baz(a: String = definedExternally): Int? = definedExternally
}
}
}
@@ -0,0 +1,112 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
class A {
class B {
class A {
@nativeGetter
fun get(a: String): Any? = null
@nativeGetter
fun take(a: Number): String? = null
@nativeGetter
fun foo(a: Double): String? = null
companion object {
@nativeGetter
fun get(a: String): Any? = null
@nativeGetter
fun take(a: Number): String? = null
@nativeGetter
fun foo(a: Double): String? = null
}
}
class B {
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj2 {}
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
}
}
class C {
@nativeGetter
fun get(): Any? = null
@nativeGetter
fun get(a: A): Any? = null
@nativeGetter
fun foo(a: Int) {}
@nativeGetter
fun bar(a: String): Int = 0
@nativeGetter
fun baz(a: String = "foo"): Int? = 0
}
object obj {
@nativeGetter
fun get(): Any? = null
@nativeGetter
fun get(a: A): Any? = null
@nativeGetter
fun foo(a: Int) {}
@nativeGetter
fun bar(a: String): Int = 0
@nativeGetter
fun baz(a: Double = 0.0): Int? = 0
}
val anonymous = object {
@nativeGetter
fun get(): Any? = null
@nativeGetter
fun get(a: A): Any? = null
@nativeGetter
fun foo(a: Int) {}
@nativeGetter
fun bar(a: String): Int = 0
@nativeGetter
fun baz(a: String = "foo"): Int? = 0
}
}
}
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
class A {
@nativeGetter
fun get(a: String): Any? = null
@nativeGetter
fun take(a: Number): String? = null
@nativeGetter
fun foo(a: Double): String? = null
companion object {
@nativeGetter
fun get(a: String): Any? = null
@nativeGetter
fun take(a: Number): String? = null
@nativeGetter
fun foo(a: Double): String? = null
}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
object Obj2 {}
}
}
class C {
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
@nativeGetter
fun get(): Any? = null
@nativeGetter
fun get(a: A): Any? = null
@nativeGetter
fun foo(a: Int) {}
@nativeGetter
fun bar(a: String): Int = 0
@nativeGetter
fun baz(a: String = "foo"): Int? = 0
}
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeGetter
fun Int.get(a: String): Int? = 1
@nativeGetter
fun Int.get2(a: Number): String? = "OK"
@nativeGetter
fun Int.get3(a: Int): String? = "OK"
@nativeGetter
fun Int.baz(a: Int = 0): String? = "OK"
@nativeGetter
fun Int.get(a: Any): Int? = 1
@nativeGetter
fun Int.get2(): String? = "OK"
@nativeGetter
fun Int.get3(a: Any, b: Int, c: Any?): String? = "OK"
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeGetter
fun toplevelFun(): Any = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
class Foo {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
fun foo() {
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
class A {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
@nativeInvoke
fun Int.ext() = 1
@nativeInvoke
fun Int.invoke(a: String, b: Int) = "OK"
val anonymous = object {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
}
}
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
@nativeInvoke
fun toplevelFun() {}
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
class Foo {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
@@ -0,0 +1,43 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
class A {
class B {
class C {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
@nativeInvoke
fun Int.ext() = 1
@nativeInvoke
fun Int.invoke(a: String, b: Int) = "OK"
}
object obj {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
}
companion object {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
}
val anonymous = object {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
}
}
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
class A {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
@nativeInvoke
fun Int.ext() = 1
@nativeInvoke
fun Int.invoke(a: String, b: Int) = "OK"
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
val baz = 0
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
object Obj {}
companion object {
@nativeInvoke
fun foo() {}
@nativeInvoke
fun invoke(a: String): Int = 0
@nativeInvoke
fun Int.ext() = 1
@nativeInvoke
fun Int.invoke(a: String, b: Int) = "OK"
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeInvoke
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeInvoke
fun toplevelFun() {}
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeInvoke<!>
class Foo {}
@@ -0,0 +1,33 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
fun foo() {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?): Any? = null
@nativeSetter
fun Int.set3(a: Double, v: String) = "OK"
@nativeSetter
fun Int.set4(a: Double, v: String): Any = 1
@nativeSetter
fun Int.set5(a: Double, v: String): CharSequence = "OK"
@nativeSetter
fun Int.set6(a: Double, v: String): Number = 1
@nativeSetter
fun Int.set(a: Any): Int? = 1
@nativeSetter
fun Int.set2(): String? = "OK"
@nativeSetter
fun Int.set3(a: Any, b: Int, c: Any?) {}
@nativeSetter
fun Any.foo(a: Double = 0.0, v: String? = null) = "OK"
}
@@ -0,0 +1,45 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
class A {
@nativeSetter
fun set(a: String, v: Any?): Any? = null
@nativeSetter
fun put(a: Number, v: String) {}
@nativeSetter
fun foo(a: Int, v: String) {}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
var foo = 0
}
class C {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?) = "OK"
@nativeSetter
fun Int.set3(a: Double, v: String?) = "OK"
@nativeSetter
fun set(): Any? = null
@nativeSetter
fun set(a: A): Any? = null
@nativeSetter
fun set(a: String, v: Any, v2: Any) {}
@nativeSetter
fun set(a: A, v: Any?) {}
@nativeSetter
fun foo(a: Int = 0, v: String) = "OK"
}
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
fun foo() {
@nativeSetter
fun toplevelFun(): Any = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
class Foo {}
}
@@ -0,0 +1,71 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
@nativeSetter
fun set(a: String, v: Any?): Any? = definedExternally
@nativeSetter
fun put(a: Number, v: String) { definedExternally }
@nativeSetter
fun foo(a: Int, v: String) { definedExternally }
@nativeSetter
fun set4(a: Double, v: String): Any = definedExternally
@nativeSetter
fun set5(a: Double, v: String): CharSequence = definedExternally
companion object {
@nativeSetter
fun set(a: String, v: Any?): Any? = definedExternally
@nativeSetter
fun put(a: Number, v: String) { definedExternally }
@nativeSetter
fun foo(a: Int, v: String) { definedExternally }
@nativeSetter
fun set4(a: Double, v: String): Any = definedExternally
@nativeSetter
fun set5(a: Double, v: String): CharSequence = definedExternally
}
}
external class B {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj2 {}
}
}
external class C {
@nativeSetter
fun set6(a: Double, v: String): Number = definedExternally
@nativeSetter
fun set(): Any? = definedExternally
@nativeSetter
fun set(a: A): Any? = definedExternally
@nativeSetter
fun set(a: String, v: Any, v2: Any) { definedExternally }
@nativeSetter
fun set(a: A, v: Any?) { definedExternally }
@nativeSetter
fun foo(a: Number, v: String = definedExternally): String = definedExternally
}
@@ -0,0 +1,92 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
external class A {
class B {
class A {
@nativeSetter
fun set(a: String, v: Any?): Any? = definedExternally
@nativeSetter
fun put(a: Number, v: String) { definedExternally }
@nativeSetter
fun foo(a: Int, v: String) { definedExternally }
@nativeSetter
fun set4(a: Double, v: String): Any = definedExternally
@nativeSetter
fun set5(a: Double, v: String): CharSequence = definedExternally
companion object {
@nativeSetter
fun set(a: String, v: Any?): Any? = definedExternally
@nativeSetter
fun put(a: Number, v: String) { definedExternally }
@nativeSetter
fun foo(a: Int, v: String) { definedExternally }
@nativeSetter
fun set4(a: Double, v: String): Any = definedExternally
@nativeSetter
fun set5(a: Double, v: String): CharSequence = definedExternally
}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo: Int = definedExternally
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj2 {}
}
}
class C {
@nativeSetter
fun set6(a: Double, v: String): Number = definedExternally
@nativeSetter
fun set(): Any? = definedExternally
@nativeSetter
fun set(a: A): Any? = definedExternally
@nativeSetter
fun set(a: String, v: Any, v2: Any) { definedExternally }
@nativeSetter
fun set(a: A, v: Any?) { definedExternally }
@nativeSetter
fun foo(a: Double = definedExternally, v: String = definedExternally): String = definedExternally
}
object obj {
@nativeSetter
fun set(): Any? = definedExternally
@nativeSetter
fun set(a: A): Any? = definedExternally
@nativeSetter
fun set(a: String, v: Any, v2: Any) { definedExternally }
@nativeSetter
fun set(a: A, v: Any?) { definedExternally }
@nativeSetter
fun foo(a: Int, v: String = definedExternally): String = definedExternally
}
}
}
@@ -0,0 +1,130 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION
class A {
class B {
class A {
@nativeSetter
fun set(a: String, v: Any?): Any? = null
@nativeSetter
fun put(a: Number, v: String) {}
@nativeSetter
fun foo(a: Int, v: String) {}
@nativeSetter
fun set4(a: Double, v: String): Any = 1
@nativeSetter
fun set5(a: Double, v: String): CharSequence = "OK"
companion object {
@nativeSetter
fun set(a: String, v: Any?): Any? = null
@nativeSetter
fun put(a: Number, v: String) {}
@nativeSetter
fun foo(a: Int, v: String) {}
}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj2 {}
}
}
class C {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?) = "OK"
@nativeSetter
fun Int.set3(a: Double, v: String?) = "OK"
@nativeSetter
fun Int.set6(a: Double, v: String): Number = 1
@nativeSetter
fun set(): Any? = null
@nativeSetter
fun set(a: A): Any? = null
@nativeSetter
fun set(a: String, v: Any, v2: Any) {}
@nativeSetter
fun set(a: A, v: Any?) {}
@nativeSetter
fun foo(a: Double = 0.0, v: String = "str") = "OK"
}
object obj {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?) = "OK"
@nativeSetter
fun Int.set3(a: Double, v: String?) = "OK"
@nativeSetter
fun set(): Any? = null
@nativeSetter
fun set(a: A): Any? = null
@nativeSetter
fun set(a: String, v: Any, v2: Any) {}
@nativeSetter
fun set(a: A, v: Any?) {}
@nativeSetter
fun foo(a: Int, v: String = "str") = "OK"
}
val anonymous = object {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?) = "OK"
@nativeSetter
fun Int.set3(a: Double, v: String?) = "OK"
@nativeSetter
fun set(): Any? = null
@nativeSetter
fun set(a: A): Any? = null
@nativeSetter
fun set(a: String, v: Any, v2: Any) {}
@nativeSetter
fun set(a: A, v: Any?) {}
@nativeSetter
fun foo(a: Number = 0.0, v: String) = "OK"
}
}
}
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
class A {
@nativeSetter
fun set(a: String, v: Any?): Any? = null
@nativeSetter
fun put(a: Number, v: String) {}
@nativeSetter
fun foo(a: Int, v: String) {}
companion object {
@nativeSetter
fun set(a: String, v: Any?): Any? = null
@nativeSetter
fun put(a: Number, v: String) {}
@nativeSetter
fun foo(a: Int, v: String) {}
}
}
class B {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj1 {}
companion object {
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val foo = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
object Obj2 {}
}
}
class C {
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?) = "OK"
@nativeSetter
fun Int.set3(a: Double, v: String?) = "OK"
@nativeSetter
fun set(): Any? = null
@nativeSetter
fun set(a: A): Any? = null
@nativeSetter
fun set(a: String, v: Any, v2: Any) {}
@nativeSetter
fun set(a: A, v: Any?) {}
@nativeSetter
fun foo(a: String = "0.0", v: String) = "OK"
}
@@ -0,0 +1,31 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeSetter
fun Int.set(a: String, v: Int) {}
@nativeSetter
fun Int.set2(a: Number, v: String?): Any? = null
@nativeSetter
fun Int.set3(a: Double, v: String) = "OK"
@nativeSetter
fun Int.set4(a: Double, v: String): Any = 1
@nativeSetter
fun Int.set5(a: Double, v: String): CharSequence = "OK"
@nativeSetter
fun Int.set6(a: Double, v: String): Number = 1
@nativeSetter
fun Any.foo(a: String = "0.0", v: String = "str") = "OK"
@nativeSetter
fun Int.set(a: <!UNRESOLVED_REFERENCE!>A<!>): Int? = 1
@nativeSetter
fun Int.set2(): String? = "OK"
@nativeSetter
fun Int.set3(a: Any, b: Int, c: Any?) {}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
@nativeSetter
fun toplevelFun(): Any = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
val toplevelVal = 0
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
class Foo {}
@@ -0,0 +1,41 @@
object O
class TopLevel {
external class A
class B
fun foo() = 23
external fun bar(): Int
val x = "a"
external val y: String
val O.u: String get() = "O.u"
}
external class TopLevelNative {
external class A
class B
fun foo(): Int = definedExternally
external fun bar(): Int
val x: String = definedExternally
external val y: String
}
fun topLevelFun() {
external class A
class B
fun foo() = 23
external fun bar(): Int
}
@@ -0,0 +1,21 @@
external interface I {
fun foo(): Unit = definedExternally
val a: Int?
get() = definedExternally
var b: String?
get() = definedExternally
set(value) = definedExternally
val c: Int
get() = definedExternally
var d: String
get() = definedExternally
set(value) = definedExternally
var e: dynamic
get() = definedExternally
set(value) = definedExternally
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNREACHABLE_CODE
// unreachable code suppressed due to KT-9586
@@ -38,4 +39,4 @@ external object O {
fun foo(s: String): String
fun bar(s: String): String = definedExternally
}
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -DEPRECATION
<!NON_MEMBER_FUNCTION_NO_BODY!>@nativeGetter
fun String.foo(n: Int): Int?<!>
@nativeGetter
fun String.bar(n: Int): Int? = definedExternally
external interface T {
@nativeGetter
fun foo(d: Double): String?
@nativeGetter
fun bar(d: Double): String?
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -DEPRECATION
<!NON_MEMBER_FUNCTION_NO_BODY!>@nativeInvoke
fun String.foo(): Int<!>
@nativeInvoke
fun String.bar(): Int = definedExternally
external object O {
@nativeInvoke
fun foo()
@nativeInvoke
fun bar() { definedExternally }
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -DEPRECATION
<!NON_MEMBER_FUNCTION_NO_BODY!>@nativeSetter
fun String.foo(n: Int, v: Any)<!>
@nativeSetter
fun String.bar(n: Int, v: Any) {}
external class C {
@nativeSetter
fun foo(d: Double, v: Any): Any
@nativeSetter
fun bar(d: Double, v: Any): Any = definedExternally
}
@@ -0,0 +1,60 @@
open external class A {
open fun f(x: Int = definedExternally)
}
class B : A() {
override fun f(x: Int) {}
}
class BB : A()
external class C : A {
override fun f(x: Int)
}
external interface I {
fun f(x: Int = definedExternally)
}
interface J {
fun f(x: Int = 23)
}
interface II {
fun f(x: Int)
}
interface IIJ : II, J
open external class D {
open fun f(x: Int)
}
class E : D() {
override fun f(x: Int) { }
}
class F : D(), I {
override fun f(x: Int) {}
}
external class G : D, I {
override fun f(x: Int)
}
open class X {
fun f(x: Int) {}
}
open external class XE {
fun f(x: Int)
}
class Y : X(), I
class YY : A(), II
external class YE: XE, I
class Z : X(), J
@@ -0,0 +1,68 @@
// !DIAGNOSTICS: -NOTHING_TO_INLINE
// TODO: should we disable NOTHING_TO_INLINE in JS backend?
// TODO: uncomment declarations in case we decide to implement KT-14031
external class C {
private fun a(): Int
private val b: String
private var c: Float
private var d: Float
get
set
var e: Float
get
private set
/*
private inline fun inline_a(): Int = 23
private inline val inline_prop: Int
get() = 42
*/
}
external object O {
private fun a(): Int
private val b: String
private var c: Float
private var d: Float
get
set
/*
private inline fun inline_a(): Int = 23
private inline val inline_prop: Int
get() = 42
*/
}
external class Outer {
class Inner {
private fun a(): Int
private val b: String
private var c: Float
private var d: Float
get
set
/*
private inline fun inline_a(): Int = 23
private inline val inline_prop: Int
get() = 42
*/
}
private class PrivateInner
}
@@ -0,0 +1 @@
external class C(x: Int, val y: String)
@@ -0,0 +1,5 @@
external interface I
fun box(a: Any, b: Any): Pair<I, I?> {
return Pair(a as I, b as? I)
}
@@ -0,0 +1,5 @@
external interface I
fun box(a: Any, b: Any): Boolean {
return a is I && b !is I
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
inline fun <reified T> foo(x: T) {
println(x)
}
external interface I
external class C : I
operator inline fun <reified T> C.plus(other: T) = this
fun bar() {
foo(C())
val c: I = C()
foo(c)
foo<I>(C())
C() + c
}
@@ -0,0 +1,5 @@
external interface I
fun box() {
println(I::class)
}
@@ -0,0 +1,9 @@
external interface I
external interface J
fun box(a: Any) = when (a) {
is I -> 0
!is J -> 1
else -> 2
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
external fun foo(a: String): Int = definedExternally
external class Bar(b: Int, c: Char) {
@@ -9,4 +10,4 @@ external object Obj {
object Nested {
fun test2(g: Int) { definedExternally }
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -DEPRECATION
@nativeGetter
fun Int.foo(a: String): Int? = definedExternally
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -DEPRECATION
@nativeInvoke
fun Int.foo(a: String): Int = definedExternally
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -DEPRECATION
@nativeSetter
fun Int.foo(a: String, v: Int): Int = definedExternally
@@ -0,0 +1,21 @@
external annotation class A(val x: Int)
val x: Int
external get() = definedExternally
class B
val B.x: Int
external get() = definedExternally
class C {
val a: Int
external get() = definedExternally
}
external class D {
val a: Int
external get() = definedExternally
}
external data class E(val x: Int)