[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,89 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
import kotlin.reflect.KClass
expect annotation class Primitives(
val z: Boolean = true,
val c: Char = 'c',
val b: Byte = 42.toByte(),
val s: Short = (-1).toShort(),
val i: Int = -42,
val f: Float = 2.72f,
val j: Long = 123456789123456789L,
val d: Double = 3.14159265358979
)
expect annotation class PrimitiveArrays(
val z: BooleanArray = [true],
val c: CharArray = ['c'],
val b: ByteArray = [42.toByte()],
val s: ShortArray = [(-1).toShort()],
val i: IntArray = [-42],
val f: FloatArray = [2.72f],
val j: LongArray = [123456789123456789L],
val d: DoubleArray = [3.14159265358979]
)
enum class En { A, B }
annotation class Anno(val value: String = "Anno")
expect annotation class Classes(
val s: String = "OK",
val e: En = En.B,
// TODO: this does not work at the moment because AnnotationDescriptor subclasses do not implement equals correctly
// val a: Anno = Anno(),
val k: KClass<*> = List::class
)
expect annotation class ClassArrays(
val s: Array<String> = ["OK"],
val e: Array<En> = [En.B],
// val a: Array<Anno> = [Anno()],
val k: Array<KClass<*>> = [List::class],
vararg val v: Int = [42]
)
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
import kotlin.reflect.KClass
actual annotation class Primitives(
actual val z: Boolean = true,
actual val c: Char = 'c',
actual val b: Byte = 42.toByte(),
actual val s: Short = (-1).toShort(),
actual val i: Int = -42,
actual val f: Float = 2.72f,
actual val j: Long = 123456789123456789L,
actual val d: Double = 3.14159265358979
)
actual annotation class PrimitiveArrays(
actual val z: BooleanArray = [true],
actual val c: CharArray = ['c'],
actual val b: ByteArray = [42.toByte()],
actual val s: ShortArray = [(-1).toShort()],
actual val i: IntArray = [-42],
actual val f: FloatArray = [2.72f],
actual val j: LongArray = [123456789123456789L],
actual val d: DoubleArray = [3.14159265358979]
)
actual annotation class Classes(
actual val s: String = "OK",
actual val e: En = En.B,
// actual val a: Anno = Anno(),
actual val k: KClass<*> = List::class
)
actual annotation class ClassArrays(
actual val s: Array<String> = ["OK"],
actual val e: Array<En> = [En.B],
// actual val a: Array<Anno> = [Anno()],
actual val k: Array<KClass<*>> = [List::class],
actual vararg val v: Int = [42]
)
@@ -0,0 +1,33 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect annotation class A1(val x: Int, val y: String = "OK")
expect annotation class A2(val x: Int = 42, val y: String = "OK")
expect annotation class A3(val x: Int, val y: String)
expect annotation class A4(val x: Int = 42, val y: String)
expect annotation class A5(val x: Int = 42, val y: String)
@A1(0)
@A2
@A3(0, "")
@A4(0, "")
@A5(0, "")
fun test() {}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual annotation class A1(actual val x: Int, actual val y: String)
actual annotation class A2(actual val x: Int, actual val y: String = "OK")
actual annotation class A3(actual val x: Int = 42, actual val y: String = "OK")
actual annotation class A4(actual val x: Int, actual val y: String = "OK")
actual annotation class A5(actual val x: Int = 239, actual val y: String = "OK")
@@ -0,0 +1,64 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect annotation class A1(val x: Int, val y: String = "OK")
expect annotation class A2(val x: Int = 42, val y: String = "OK")
expect annotation class A3(val x: Int, val y: String)
expect annotation class A4(val x: Int = 42, val y: String)
expect annotation class A5(val x: Int = 42, val y: String)
@A1(0)
@A2
@A3(0, "")
@A4(0, "")
@A5(0, "")
fun test() {}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias A1 = J1
actual typealias A2 = J2
actual typealias A3 = J3
actual typealias A4 = J4
actual typealias A5 = J5
// FILE: J1.java
public @interface J1 {
int x();
String y();
}
// FILE: J2.java
public @interface J2 {
int x();
String y() default "OK";
}
// FILE: J3.java
public @interface J3 {
int x() default 42;
String y() default "OK";
}
// FILE: J4.java
public @interface J4 {
int x();
String y() default "OK";
}
// FILE: J5.java
public @interface J5 {
int x() default 239;
String y() default "OK";
}
@@ -0,0 +1,79 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
// See also compiler/testData/codegen/boxAgainstJava/multiplatform/annotationsViaActualTypeAliasFromBinary.kt
import kotlin.reflect.KClass
expect annotation class Anno(
val b: Byte = 1.toByte(),
val c: Char = 'x',
val d: Double = 3.14,
val f: Float = -2.72f,
val i: Int = 42424242,
val i2: Int = 53535353,
val j: Long = 239239239239239L,
val j2: Long = 239239L,
val s: Short = 42.toShort(),
val z: Boolean = true,
val ba: ByteArray = [(-1).toByte()],
val ca: CharArray = ['y'],
val da: DoubleArray = [-3.14159],
val fa: FloatArray = [2.7218f],
val ia: IntArray = [424242],
val ja: LongArray = [239239239239L, 239239L],
val sa: ShortArray = [(-43).toShort()],
val za: BooleanArray = [false, true],
val str: String = "fizz",
val k: KClass<*> = Number::class,
val e: E = E.E1,
// TODO: val a: A = A("1"),
val stra: Array<String> = ["bu", "zz"],
val ka: Array<KClass<*>> = [Double::class, String::class, LongArray::class, Array<Array<Array<Int>>>::class, Unit::class],
val ea: Array<E> = [E.E2, E.E3]
// TODO: val aa: Array<A> = [A("2"), A("3")]
)
enum class E { E1, E2, E3 }
annotation class A(val value: String)
@Anno
fun test() {}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias Anno = Jnno
// FILE: Jnno.java
public @interface Jnno {
byte b() default 1;
char c() default 'x';
double d() default 3.14;
float f() default -2.72f;
int i() default 42424242;
int i2() default 21212121 + 32323232;
long j() default 239239239239239L;
long j2() default 239239;
short s() default 42;
boolean z() default true;
byte[] ba() default {-1};
char[] ca() default {'y'};
double[] da() default {-3.14159};
float[] fa() default {2.7218f};
int[] ia() default {424242};
long[] ja() default {239239239239L, 239239};
short[] sa() default {-43};
boolean[] za() default {false, true};
String str() default "fi" + "zz";
Class<?> k() default Number.class;
E e() default E.E1;
// TODO: A a() default @A("1");
String[] stra() default {"bu", "zz"};
Class<?>[] ka() default {double.class, String.class, long[].class, Integer[][][].class, void.class};
E[] ea() default {E.E2, E.E3};
// TODO: A[] aa() default {@A("2"), @A("3")};
}
@@ -0,0 +1,23 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Ok(x: Int, y: String = "")
expect class FailX(x: Int, y: String = "")
expect class FailY(x: Int, y: String = "")
fun test() {
Ok(42)
Ok(42, "OK")
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Ok actual constructor(x: Int, y: String)
actual class FailX actual constructor(x: Int = 0, y: String)
actual class FailY actual constructor(x: Int, y: String = "")
@@ -0,0 +1,41 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun ok(x: Int, y: String = "")
expect fun failX(x: Int, y: String = "")
expect fun failY(x: Int, y: String = "")
expect open class Foo {
fun ok(x: Int, y: String = "")
fun failX(x: Int, y: String = "")
fun failY(x: Int, y: String = "")
}
fun test(foo: Foo) {
ok(42)
ok(42, "OK")
foo.ok(42)
foo.ok(42, "OK")
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun ok(x: Int, y: String) {}
actual fun failX(x: Int = 0, y: String) {}
actual fun failY(x: Int, y: String = "") {}
actual open class Foo {
actual fun ok(x: Int, y: String) {}
actual fun failX(x: Int = 0, y: String) {}
actual fun failY(x: Int, y: String = "") {}
}
@@ -0,0 +1,37 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface Foo {
fun ok(x: Int, y: String = "")
fun failX(x: Int, y: String = "")
fun failY(x: Int, y: String = "")
}
expect class Bar : Foo {
override fun ok(x: Int, y: String)
override fun failX(x: Int, y: String)
override fun failY(x: Int, y: String)
}
fun test(foo: Foo, bar: Bar) {
foo.ok(42)
foo.ok(42, "OK")
bar.ok(42)
bar.ok(42, "OK")
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Bar : Foo {
actual override fun ok(x: Int, y: String) {}
actual override fun failX(x: Int = 0, y: String) {}
actual override fun failY(x: Int, y: String = "") {}
}
@@ -0,0 +1,17 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: m1-common
// FILE: common.kt
expect fun ok(x: Int, y: String = "")
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun ok(x: Int, y: String) {}
fun ok(x: Int, y: Long = 1L) {}
fun test() {
ok(1)
}
@@ -0,0 +1,30 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
header class My
header fun foo(): Int
header val x: String
header object O
header enum class E {
FIRST
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
impl class My
impl fun foo() = 42
impl val x get() = "Hello"
impl object O
impl enum class E {
FIRST
}
@@ -0,0 +1,10 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class Foo { A, B }
expect enum class Bar { X, Y, Z }
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual enum class Foo { A, B, C, D, E }
actual enum class Bar { V, X, W, Y, Z }
@@ -0,0 +1,15 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class En(x: Int) {
E1,
E2(42),
;
<!INAPPLICABLE_CANDIDATE!>constructor(s: String)<!>
}
expect enum class En2 {
E1()
}
@@ -0,0 +1,10 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class Foo { A, B }
expect enum class Bar { X, Y, Z }
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual enum class Foo { B, A }
actual enum class Bar { X, Z, Y }
@@ -0,0 +1,11 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class En {
E1,
E2 {
fun foo() = ""
},
E3 { };
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class Foo {
ENTRY
}
expect enum class _TimeUnit
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias Foo = FooImpl
actual typealias _TimeUnit = java.util.concurrent.TimeUnit
// FILE: FooImpl.java
public enum FooImpl {
ENTRY("OK") {
@Override
public String getResult() {
return value;
}
};
protected final String value;
public FooImpl(String value) {
this.value = value;
}
public abstract String getResult();
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect enum class Foo {
ENTRY1,
ENTRY2,
ENTRY3;
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual enum class Foo(val x: String) {
ENTRY1("1"),
ENTRY2("2"),
ENTRY3("3");
}
@@ -0,0 +1,12 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun <T : Comparable<T>> Array<out T>.sort(): Unit
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {}
fun <T> Array<out T>.sort(): Unit {}
@@ -0,0 +1,25 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class A {
fun <T : Any> foo(): Unit
fun <S : Comparable<S>> bar(): List<S>
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias A = JavaA
// FILE: JavaA.java
import java.util.List;
public class JavaA {
public <T> void foo() {}
public <S extends Comparable<S>> List<S> bar() {
return null;
}
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect interface A<T> {
val x: T
var y: List<T>
fun f(p: Collection<T>): Map<T, A<T?>>
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual interface A<T> {
actual val x: T
actual var y: List<T>
actual fun f(p: Collection<T>): Map<T, A<T?>>
}
@@ -0,0 +1,13 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface A
interface B
expect fun <T> List<T>.foo() where T : A, T : B
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
fun <T> List<T>.foo() where T : B, T : A {}
@@ -0,0 +1,48 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect annotation class Foo1
expect annotation class Foo2
expect annotation class Foo3
expect annotation class Foo4
expect annotation class Foo5()
expect annotation class Foo6()
expect annotation class Foo7()
@Foo1
fun foo() {}
@Foo5
fun bar() {}
// MODULE: m2-jvm(m1-common)
// FILE: Bar1.java
public @interface Bar1 {
String value() default "";
}
// FILE: Bar2.java
public @interface Bar2 {
String value() default "";
String path();
}
// FILE: jvm.kt
actual typealias Foo1 = Bar1
actual typealias Foo4 = Bar2
actual annotation class Foo2(val p: String = "default")
actual annotation class Foo3(val a: String = "a", val b: String = "b")
actual annotation class Foo5
actual annotation class Foo6(val s: String = "value")
actual typealias Foo7 = Bar2
@@ -0,0 +1,55 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo1
expect class Foo2
expect class Foo3
expect class Bar1()
expect class Bar2()
expect class Bar3()
expect class Bar4()
expect class Bar5()
expect class Bar6()
expect class Bar7(s: String)
// MODULE: m2-jvm(m1-common)
// FILE: JavaFoo.java
public class JavaFoo {
public JavaFoo(int i) {}
}
// FILE: JavaBar.java
public class JavaBar {
public JavaBar(int i) {}
}
// FILE: jvm.kt
actual class Foo1(val s: String)
actual class Foo2(val p: String = "value", i: Int)
actual typealias Foo3 = JavaFoo
actual class Bar1(val s: String)
actual class Bar2(val p: String = "value", i: Int)
actual typealias Bar3 = JavaBar
actual class Bar4(val s: String) {
constructor() : this("")
}
actual class Bar5 {
actual constructor()
constructor(s: String)
}
class Bar6 {
actual constructor()
}
actual class Bar7 actual constructor(s: String) {
constructor() : this("")
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class A {
fun foo()
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
class A {
actual fun foo() {}
}
@@ -0,0 +1,13 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A
expect class B : A
open class C : A
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual open class A
actual class B : A()
@@ -0,0 +1,26 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect interface Interface
expect annotation class Anno(val prop: String)
expect object Object
expect class Class
expect enum class En { ENTRY }
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual interface Interface
actual annotation class Anno actual constructor(actual val prop: String)
actual object Object
actual class Class
actual enum class En { ENTRY }
@@ -0,0 +1,28 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface Foo {
fun foo()
}
expect class ImplicitFoo : Foo
expect class ExplicitFoo : Foo {
override fun foo()
}
expect class ImplicitFooCheck : Foo
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class ImplicitFoo : Foo {
override fun foo() {}
}
actual class ExplicitFoo : Foo {
actual override fun foo() {}
}
actual class ImplicitFooCheck : Foo
@@ -0,0 +1,23 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface Foo {
fun foo()
}
expect class NonAbstractClass : Foo {
abstract fun bar()
abstract val baz: Int
abstract override fun foo()
}
expect abstract class AbstractClass : Foo {
abstract fun bar()
abstract val baz: Int
abstract override fun foo()
}
@@ -0,0 +1,25 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo
expect class Bar()
expect class Baz constructor()
expect class FooBar {
constructor()
}
fun test() {
Foo()
Bar()
Baz()
FooBar()
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo
actual class Bar
actual class Baz
actual class FooBar
@@ -0,0 +1,33 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: m1-common
// FILE: common.kt
expect fun foo1(x: Int)
expect fun foo2(x: Int)
expect class NoArgConstructor()
expect fun foo3(): Int
expect fun foo4(): Int
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun foo1(x: Int) {}
fun foo1(x: Int, y: Int) {}
fun foo1(x: String) {}
fun foo2(x: Int, y: Int) {}
fun foo2(x: String) {}
actual fun foo3(): String = ""
fun foo4(x: Int): String = ""
actual class NoArgConstructor {
actual constructor()
actual constructor(x: Int)
constructor(x: String)
}
@@ -0,0 +1,28 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: m1-common
// FILE: common.kt
expect class Foo1
expect class Foo2
expect fun foo2(): Int
expect val s: String
expect open class Foo3
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
interface Foo1
actual interface Foo2
actual var s: String = "value"
fun foo2(): Int = 0
actual class Foo3
class Foo3
@@ -0,0 +1,27 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
fun f()
val v: String
}
expect class Bar {
fun g()
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual open class Foo(actual open val v: String) {
actual open fun f() {}
}
actual typealias Bar = JavaBar
// FILE: JavaBar.java
public class JavaBar {
public void g() {}
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A {
constructor(s: String)
constructor(n: Number) : this("A")
}
expect class B : A {
constructor(i: Int)
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>("B")
}
@@ -0,0 +1,62 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect abstract class BaseA() {
abstract fun foo()
}
expect open class BaseAImpl() : BaseA
class DerivedA1 : BaseAImpl()
class DerivedA2 : BaseAImpl() {
override fun foo() = super.foo()
}
expect interface BaseB {
fun foo()
}
expect open class BaseBImpl() : BaseB
class DerivedB1 : BaseBImpl()
class DerivedB2 : BaseBImpl() {
override fun foo() = super.foo()
}
expect interface BaseC {
fun foo()
}
expect abstract class BaseCImpl() : BaseC
class DerivedC1 : BaseCImpl()
class DerivedC2 : BaseCImpl() {
override fun foo() = super.foo()
}
expect interface BaseD {
fun foo()
}
abstract class BaseDImpl() : BaseD {
fun bar() = super.foo()
}
expect interface BaseE {
fun foo()
}
sealed class BaseEImpl() : BaseE {
fun bar() = super.foo()
}
expect interface BaseF {
fun foo()
}
expect class BaseFImpl() : BaseF
@@ -0,0 +1,36 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect abstract class Base {
abstract fun foo()
}
expect class DerivedImplicit : Base
expect class DerivedExplicit : Base {
override fun foo()
}
expect class DerivedExplicitCheck : Base {
override fun foo()
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual abstract class Base {
actual abstract fun foo()
}
actual class DerivedImplicit : Base() {
override fun foo() {}
}
actual class DerivedExplicit : Base() {
actual override fun foo() {}
}
actual class DerivedExplicitCheck : Base() {
override fun foo() {}
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class H {
expect fun foo()
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual class H {
actual fun foo() {}
}
@@ -0,0 +1,15 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
val bar: String
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual class Foo {
actual val bar = "bar"
fun bar() = bar
}
@@ -0,0 +1,31 @@
// !DIAGNOSTICS: -ACTUAL_WITHOUT_EXPECT
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class C1
expect interface C2<A>
expect interface C3<B>
expect interface C4<D, E>
expect interface C5<F, G>
expect interface C6<H>
expect interface C7<I>
expect interface C8<J>
expect interface C9<K>
expect interface C10<L>
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias C1 = String
actual typealias C2<A> = List<String>
actual typealias C3<B> = List<B>
actual typealias C4<D, E> = MutableMap<D, E>
actual typealias C5<F, G> = MutableMap<G, F>
actual typealias C6<H> = MutableList<H>
actual typealias C7<I> = MutableList<out I>
actual typealias C8<J> = MutableList<*>
actual typealias C9<K> = MutableList<in K>
typealias Tmp<K> = MutableList<K>
actual typealias C10<L> = Tmp<L>
@@ -0,0 +1,24 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
val foo: String
fun bar(x: Int): Int
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo {
actual val foo: String = "JVM"
actual fun bar(x: Int): Int = x + 1
}
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual class Foo {
actual val foo: String = "JS"
actual fun bar(x: Int): Int = x - 1
}
@@ -0,0 +1,27 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo(
val constructorProperty: String,
constructorParameter: String
) {
init {
"no"
}
constructor(s: String) {
"no"
}
constructor() : this("no")
val prop: String = "no"
var getSet: String
get() = "no"
set(value) {}
fun functionWithBody(x: Int): Int {
return x + 1
}
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo(x: Int, y: String) {
val x: Int
val y: String
}
expect class Bar(z: Double)
expect class Baz(w: List<String>) {
val w: List<String>
operator fun component1(): List<String>
// Disabled because default arguments are not allowed
// fun copy(w: List<T> = ...): Baz<T>
override fun equals(other: Any?): Boolean
override fun hashCode(): Int
override fun toString(): String
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual data class Foo actual constructor(actual val x: Int, actual val y: String)
actual data class Bar actual constructor(val z: Double)
actual data class Baz actual constructor(actual val w: List<String>)
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo
expect fun getFoo(): Foo
fun <T : Foo> bar() {} // no "Foo is final" warning should be here
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual open class Foo
class Bar : Foo()
actual fun getFoo(): Foo = Bar()
@@ -0,0 +1,10 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface A
class B : A
expect class Foo(b: B) : A by b
expect class Bar : A by B()
@@ -0,0 +1,31 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
val justVal: String
var justVar: String
val String.extensionVal: Unit
var <T> T.genericExtensionVar: T
val valWithGet: String
get
var varWithGetSet: String
get set
val backingFieldVal: String = "no"
var backingFieldVar: String = "no"
val customAccessorVal: String
get() = "no"
var customAccessorVar: String
get() = "no"
set(value) {}
lateinit var lateinitVar: String
val delegated: String by Delegate
}
object Delegate { operator fun getValue(x: Any?, y: Any?): String = "" }
@@ -0,0 +1,35 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo1 {
val x: String
}
expect class Foo2 {
val x: String
}
expect class Foo3 {
val x: String
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
open class Open {
open val x = "42"
}
actual open class Foo1 : Open() {
override val x = super.x
}
actual open class Foo2 : Open()
open class WithFinal {
val x = "42"
}
actual open class Foo3 : WithFinal()
@@ -0,0 +1,39 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: m1-common
// FILE: common.kt
expect open class Container {
fun publicFun()
internal fun internalFun1()
internal fun internalFun2()
internal fun internalFun3()
protected fun protectedFun1()
protected fun protectedFun2()
protected fun protectedFun3()
open internal fun openInternalFun()
open fun openPublicFun()
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual open class Container {
actual fun publicFun() {} // OK: public -> public
actual fun internalFun1() {} // OK: internal -> public
actual internal fun internalFun2() {} // OK: internal -> internal
actual fun protectedFun1() {} // OK: protected -> public
actual protected fun protectedFun2() {} // OK: protected -> protected
actual internal fun protectedFun3() {} // BAD: protected -> internal
actual protected fun internalFun3() {} // BAD: internal -> protected
actual open fun openInternalFun() {} // BAD: internal+open -> public
actual internal fun openPublicFun() {} // BAD: open+public -> internal
}
@@ -0,0 +1,22 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: m1-common
// FILE: common.kt
expect open class Container {
internal fun internalFun()
}
// MODULE: m2-jvm(m1-common)
// FILE: foo/Foo.java
package foo;
public class Foo {
public final void internalFun() {} // OK: internal -> public
}
// FILE: jvm.kt
actual typealias Container = foo.Foo
@@ -0,0 +1,58 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class OuterClass {
class NestedClass {
class DeepNested {
class Another {
fun f(s: String)
val p: Int
}
}
}
inner class InnerClass {
fun f(x: Int)
val p: String
}
companion object
}
expect class OuterClassWithNamedCompanion {
companion object Factory
}
expect object OuterObject {
object NestedObject
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class OuterClass {
actual class NestedClass {
actual class DeepNested {
actual class Another {
actual fun f(s: String) {}
actual val p: Int = 42
}
}
}
actual inner class InnerClass {
actual fun f(x: Int) {}
actual val p: String = ""
}
actual companion object
}
actual class OuterClassWithNamedCompanion {
actual companion object Factory
}
actual object OuterObject {
actual object NestedObject
}
@@ -0,0 +1,46 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class B {
class N {
fun body() {}
expect fun extraHeader()
}
}
expect class C {
expect class N
expect enum class E
expect inner class I
}
expect class D {
class N
}
expect class E {
class N
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual class B {
actual class N {
actual fun body() {}
actual fun extraHeader() {}
}
}
actual class C {
actual class N
actual enum class E
actual inner class I
}
actual class D
actual class E {
class N
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
fun bar(): String
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo {
fun bar(): String = "bar"
}
@@ -0,0 +1,22 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class A {
private fun foo()
private val bar: String
private fun Int.memExt(): Any
private class Nested
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual class A {
private fun foo() {}
private val bar: String = ""
actual private fun Int.memExt(): Any = 0
actual private class Nested
}
@@ -0,0 +1,12 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual class Foo
@@ -0,0 +1,13 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo { // also, it's important that Foo doesn't override equals
fun foo()
}
fun check(x1: Foo, x: Any) {
if (x1 == x) {
x.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
@@ -0,0 +1,23 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
interface I
open class C
interface J
expect class Foo : I, C, J
expect class Bar : C()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo : I, C(), J
actual class Bar
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual class Foo : I, J, C()
actual class Bar : C()
@@ -0,0 +1,10 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
class Foo {
expect fun bar(): String
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
@@ -0,0 +1,19 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class Foo {
open fun bar(): String
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
interface Bar {
fun bar(): String
}
val bar: Bar
get() = null!!
actual open class Foo : Bar by bar
@@ -0,0 +1,29 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNSUPPORTED
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
constructor(p: Any)
fun f1(s: String): Int
fun f2(s: List<String>?): MutableMap<Boolean?, Foo>
fun <T : Set<Number>> f3(t: T): T?
}
// MODULE: m2-js(m1-common)
// FILE: js.kt
// TODO: do not suppress UNSUPPORTED once JS files in multi-platform tests are analyzed with JS analyzer facade
actual class Foo {
actual constructor(p: dynamic) {}
actual fun f1(s: dynamic): dynamic = null!!
actual fun f2(s: dynamic): MutableMap<Boolean?, Foo> = null!!
actual fun <T : Set<Number>> f3(t: T): dynamic = null!!
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
fun bar(): String
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
open class Bar {
fun bar() = "bar"
}
actual class Foo : Bar()
@@ -0,0 +1,13 @@
// !LANGUAGE: +MultiPlatformProjects
header impl class First
header expect class Second
header actual class Third
impl expect class Fourth
impl actual class Fifth
expect actual class Sixth
@@ -0,0 +1,28 @@
// !LANGUAGE: +MultiPlatformProjects, +InlineClasses
// MODULE: m1-common
// FILE: common.kt
expect inline class Foo1(val x: Int) {
fun bar(): String
}
expect inline class Foo2(val x: Int)
expect inline class Foo3
expect class NonInlineExpect
expect inline class NonInlineActual(val x: Int)
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual inline class Foo1(val x: Int) {
actual fun bar(): String = "Hello"
}
actual inline class Foo2(val x: String)
actual inline class Foo3
actual inline class NonInlineExpect(val x: Int)
actual class NonInlineActual actual constructor(actual val x: Int)
@@ -0,0 +1,32 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
constructor(p: Any)
fun f1(s: String): Int
fun f2(s: List<String>?): MutableMap<Boolean?, Foo>
fun <T : Set<Number>> f3(t: T): T?
}
// MODULE: m2-jvm(m1-common)
// FILE: FooImpl.java
import java.util.*;
public class FooImpl {
public FooImpl(Object p) {}
public final int f1(String s) { return 0; }
public final Map<Boolean, FooImpl> f2(List<String> s) { return null; }
public final <T extends Set<Number>> T f3(T t) { return null; }
}
// FILE: jvm.kt
actual typealias Foo = FooImpl
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
fun foo(i: Int, d: Double, f: Float): Unit
}
// MODULE: m2-jvm(m1-common)
// FILE: FooImpl.java
public class FooImpl {
public final void foo(int d, double i, float f) {}
}
// FILE: jvm.kt
actual typealias Foo = FooImpl
@@ -0,0 +1,35 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect typealias Foo = String
class Outer expect constructor() {
expect class Nested
expect init {}
expect fun foo()
expect val bar: Int
}
fun foo() {
expect fun localFun()
expect var x = 42
expect class Bar
}
// MODULE: m2-jvm
// FILE: jvm.kt
class Outer actual constructor() {
actual class Nested
actual init {}
}
fun foo() {
actual fun localFun() {}
actual var x = 42
actual class Bar
}
@@ -0,0 +1,37 @@
// !WITH_NEW_INFERENCE
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class Foo(zzz: Int) {
<!INAPPLICABLE_CANDIDATE!>constructor(aaa: Boolean)<!>
fun f1(xxx: String): String
}
expect fun f2(xxx: Int)
fun testCommon() {
Foo(zzz = 0)
val f = Foo(aaa = true)
f.f1(xxx = "")
f2(xxx = 42)
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual class Foo actual constructor(val aaa: Boolean) {
actual constructor(zzz: Int) : this(zzz == 0)
actual fun f1(xxx: String) = xxx
}
actual fun f2(xxx: Int) {}
fun testPlatform() {
Foo(zzz = 0)
val f = Foo(aaa = true)
f.f1(xxx = "")
f2(xxx = 42)
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
private expect fun foo()
private expect val bar: String
private expect fun Int.memExt(): Any
private expect class Foo
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
private actual fun foo() {}
private actual val bar: String = ""
private actual fun Int.memExt(): Any = 0
private actual class Foo
@@ -0,0 +1,17 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect sealed class Presence {
object Online: Presence
object Offline: Presence
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias Presence = P
sealed class P {
object Online : P()
object Offline : P()
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect sealed class Presence
expect object Online: Presence
expect object Offline: Presence
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual typealias Presence = P
sealed class P
actual object Online : P()
actual object Offline : P()
@@ -0,0 +1,25 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo(x: Int): Int
fun callFromCommonCode(x: Int) = foo(x)
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun foo(x: Int): Int {
return x + 1
}
fun callFromJVM(x: Int) = foo(x)
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual fun foo(x: Int): Int {
return x - 1
}
fun callFromJS(x: Int) = foo(x)
@@ -0,0 +1,21 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
package test
expect fun foo(): String
fun g(f: () -> String): String = f()
fun test() {
g(::foo)
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
package test
@Deprecated("To check that ::foo is resolved to actual fun foo when compiling common+jvm")
actual fun foo(): String = ""
@@ -0,0 +1,8 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
expect fun foo()
expect fun foo(x: Int)
@@ -0,0 +1,17 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun foo() {}
actual fun foo() {}
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual fun foo() {}
actual fun foo() {}
@@ -0,0 +1,19 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -NOTHING_TO_INLINE
// MODULE: m1-common
// FILE: common.kt
expect fun external()
expect fun tailrec()
expect fun inline()
expect fun String.unaryMinus(): String
expect fun String.and(other: String): String
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual external fun external()
actual tailrec fun tailrec(): Unit = if (true) Unit else tailrec()
actual inline fun inline() {}
actual operator fun String.unaryMinus(): String = this
actual infix fun String.and(other: String): String = this + other
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
package common
expect fun foo()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
package jvm
actual fun foo() {}
// MODULE: m3-js(m1-common)
// FILE: js.kt
package js
actual fun foo() {}
@@ -0,0 +1,9 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
expect fun foo() {}
expect fun bar() {}
@@ -0,0 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
@@ -0,0 +1,12 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun foo()
actual fun bar()
@@ -0,0 +1,5 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-jvm
// FILE: jvm.kt
actual fun foo() { }
@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
inline expect fun inlineFun()
expect fun nonInlineFun()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun inlineFun() { }
actual fun nonInlineFun() { }
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual inline fun inlineFun() { }
actual inline fun nonInlineFun() { }
@@ -0,0 +1,12 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect fun foo()
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual fun foo() {}
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual fun foo() {}
@@ -0,0 +1,27 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -NOTHING_TO_INLINE
// MODULE: m1-common
// FILE: common.kt
expect fun f1(s: () -> String)
expect inline fun f2(s: () -> String)
expect inline fun f3(noinline s: () -> String)
expect fun f4(s: () -> String)
expect inline fun f5(s: () -> String)
expect inline fun f6(crossinline s: () -> String)
expect fun f7(x: Any)
expect fun f8(vararg x: Any)
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual inline fun f1(noinline s: () -> String) {}
actual inline fun f2(noinline s: () -> String) {}
actual inline fun f3(s: () -> String) {}
actual inline fun f4(crossinline s: () -> String) {}
actual inline fun f5(crossinline s: () -> String) {}
actual inline fun f6(s: () -> String) {}
actual fun f7(vararg x: Any) {}
actual fun f8(x: Any) {}
@@ -0,0 +1,40 @@
// !LANGUAGE: +MultiPlatformProjects +LateinitTopLevelProperties
// MODULE: m1-common
// FILE: common.kt
expect val justVal: String
expect var justVar: String
expect val String.extensionVal: Unit
expect var <T> T.genericExtensionVar: T
expect val valWithGet: String
get
expect var varWithGetSet: String
get set
expect var varWithPlatformGetSet: String
expect get
expect set
expect val backingFieldVal: String = "no"
expect var backingFieldVar: String = "no"
expect val customAccessorVal: String
get() = "no"
expect var customAccessorVar: String
get() = "no"
set(value) {}
expect const val constVal: Int
expect lateinit var lateinitVar: String
expect val delegated: String by Delegate
object Delegate { operator fun getValue(x: Any?, y: Any?): String = "" }
fun test(): String {
expect val localVariable: String
localVariable = "no"
return localVariable
}
@@ -0,0 +1,12 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect var foo: String
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
actual var foo: String = "JVM"
// MODULE: m3-js(m1-common)
// FILE: js.kt
actual var foo: String = "JS"