Make FIR multi-module tests from IDE regular FIR compiler resolve tests

This commit is contained in:
Mikhail Glukhikh
2020-06-24 15:56:47 +03:00
parent 79691feb8f
commit 699829ccb3
105 changed files with 564 additions and 527 deletions
@@ -0,0 +1,22 @@
// FILE: Annotated.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class Annotated {
@NotNull
public String foo(@Nullable String param) {
if (param != null) return param;
else return "";
}
}
// FILE: jvm.kt
class User : Annotated() {
fun test() {
val x = foo("123")
val y = foo(null)
}
}
@@ -0,0 +1,12 @@
FILE: jvm.kt
public final class User : R|Annotated| {
public constructor(): R|User| {
super<R|Annotated|>()
}
public final fun test(): R|kotlin/Unit| {
lval x: R|kotlin/String| = this@R|/User|.R|/Annotated.foo|(String(123))
lval y: R|kotlin/String| = this@R|/User|.R|/Annotated.foo|(Null(null))
}
}
@@ -0,0 +1,29 @@
// FILE: Annotated.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class Annotated {
@NotNull
public String foo(@Nullable String param) {
if (param != null) return param;
else return "";
}
}
// FILE: AnnotatedDerived.java
public class AnnotatedDerived extends Annotated {
public String foo(String param) {
return super.foo(param);
}
}
// FILE: jvm.kt
class User : AnnotatedDerived() {
fun test() {
val x = foo("123")
val y = foo(null)
}
}
@@ -0,0 +1,12 @@
FILE: jvm.kt
public final class User : R|AnnotatedDerived| {
public constructor(): R|User| {
super<R|AnnotatedDerived|>()
}
public final fun test(): R|kotlin/Unit| {
lval x: R|kotlin/String| = this@R|/User|.R|/AnnotatedDerived.foo|(String(123))
lval y: R|kotlin/String| = this@R|/User|.R|/AnnotatedDerived.foo|(Null(null))
}
}
@@ -0,0 +1,9 @@
// FILE: Some.java
public class Some {
}
// FILE: jvm.kt
class A : Some()
@@ -0,0 +1,7 @@
FILE: jvm.kt
public final class A : R|Some| {
public constructor(): R|A| {
super<R|Some|>()
}
}
@@ -0,0 +1,19 @@
// FILE: A.java
public class A<T> {
public T foo(T t) {
return t;
}
}
// FILE: simpleFakeOverride.kt
class Some
class B : A<Some>() {
fun test() {
foo(Some())
}
}
@@ -0,0 +1,17 @@
FILE: simpleFakeOverride.kt
public final class Some : R|kotlin/Any| {
public constructor(): R|Some| {
super<R|kotlin/Any|>()
}
}
public final class B : R|A<Some>| {
public constructor(): R|B| {
super<R|A<Some>|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/B|.R|FakeOverride</B.foo: R|ft<Some, Some?>!|>|(R|/Some.Some|())
}
}
@@ -0,0 +1,26 @@
// FILE: Some.java
public class Some {
public boolean foo(int param) {
return param > 0;
}
public String[] bar(int[] arr) {
String[] result = new String[arr.length];
int i = 0;
for (int elem: arr) {
result[i++] = elem;
}
return result;
}
}
// FILE: jvm.kt
class A : Some() {
fun test() {
val res1 = foo(1)
val res2 = foo(-1)
val res3 = bar(intArrayOf(0, 2, -2))
}
}
@@ -0,0 +1,13 @@
FILE: jvm.kt
public final class A : R|Some| {
public constructor(): R|A| {
super<R|Some|>()
}
public final fun test(): R|kotlin/Unit| {
lval res1: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1))
lval res2: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1).R|kotlin/Int.unaryMinus|())
lval res3: R|ft<kotlin/Array<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2), Int(2).R|kotlin/Int.unaryMinus|())))
}
}
@@ -0,0 +1,13 @@
// FILE: Base.java
public class Base {
public int value = 0;
}
// FILE: Derived.kt
class Derived : Base() {
fun getValue() = value
fun foo() = value
}
@@ -0,0 +1,15 @@
FILE: Derived.kt
public final class Derived : R|Base| {
public constructor(): R|Derived| {
super<R|Base|>()
}
public final fun getValue(): R|kotlin/Int| {
^getValue this@R|/Derived|.R|/Base.value|
}
public final fun foo(): R|kotlin/Int| {
^foo this@R|/Derived|.R|/Base.value|
}
}
@@ -0,0 +1,32 @@
// FILE: Diagnostic.java
package jvm;
public interface Diagnostic {}
// FILE: DiagnosticWithParameters1.java
package jvm;
public interface DiagnosticWithParameters1<E, A> extends Diagnostic {
A getA();
}
// FILE: DiagnosticWithParameters2.java
package jvm;
public interface DiagnosticWithParameters2<E, A, B> extends Diagnostic {
A getA();
B getB();
}
// FILE: test.kt
package jvm;
fun <K> select(x: K, y: K): K = x
fun test(d1: DiagnosticWithParameters1<*, *>, d2: DiagnosticWithParameters2<*, *, *>) {
val res = select(d1.a, d2.b)
}
@@ -0,0 +1,7 @@
FILE: test.kt
public final fun <K> select(x: R|K|, y: R|K|): R|K| {
^select R|<local>/x|
}
public final fun test(d1: R|DiagnosticWithParameters1<*, *>|, d2: R|DiagnosticWithParameters2<*, *, *>|): R|kotlin/Unit| {
lval res: R|ft<kotlin/Any, kotlin/Any?>!| = R|jvm/select|<R|ft<kotlin/Any, kotlin/Any?>!|>(R|<local>/d1|.R|/DiagnosticWithParameters1.a|, R|<local>/d2|.R|/DiagnosticWithParameters2.b|)
}
@@ -0,0 +1,22 @@
// FILE: JavaClass.java
public class JavaClass {
public String getText() {
return "Text";
}
public String getText(String param) {
return "Text with " + param;
}
}
// FILE: Test.kt
fun test() {
val jc = JavaClass()
val result = jc.text
}
fun otherTest(jc: JavaClass) {
val result = jc.text
}
@@ -0,0 +1,8 @@
FILE: Test.kt
public final fun test(): R|kotlin/Unit| {
lval jc: R|JavaClass| = R|/JavaClass.JavaClass|()
lval result: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/jc|.R|/JavaClass.text|
}
public final fun otherTest(jc: R|JavaClass|): R|kotlin/Unit| {
lval result: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/jc|.R|/JavaClass.text|
}
@@ -0,0 +1,22 @@
// FILE: JavaClass.java
public class JavaClass extends Derived {
}
// FILE: Base.kt
open class Base {
open val some: String get() = "Base"
}
open class Derived : Base() {
override val some: String get() = "Derived"
}
// FILE: Test.kt
fun test() {
val jc = JavaClass()
val result = jc.some
}
@@ -0,0 +1,28 @@
FILE: Base.kt
public open class Base : R|kotlin/Any| {
public constructor(): R|Base| {
super<R|kotlin/Any|>()
}
public open val some: R|kotlin/String|
public get(): R|kotlin/String| {
^ String(Base)
}
}
public open class Derived : R|Base| {
public constructor(): R|Derived| {
super<R|Base|>()
}
public open override val some: R|kotlin/String|
public get(): R|kotlin/String| {
^ String(Derived)
}
}
FILE: Test.kt
public final fun test(): R|kotlin/Unit| {
lval jc: R|JavaClass| = R|/JavaClass.JavaClass|()
lval result: R|kotlin/String| = R|<local>/jc|.R|/Derived.some|
}
@@ -0,0 +1,21 @@
// FILE: Inheritor.java
public class Inheritor extends Second {
public void foo(First first, String s, int i) {}
}
// FILE: Base.kt
interface First
open class Second {
open fun First.foo(s: String, i: Int) {}
}
// FILE: Test.kt
class Tester : Inheritor(), First {
fun test() {
foo("abc", 456)
}
}
@@ -0,0 +1,23 @@
FILE: Base.kt
public abstract interface First : R|kotlin/Any| {
}
public open class Second : R|kotlin/Any| {
public constructor(): R|Second| {
super<R|kotlin/Any|>()
}
public open fun R|First|.foo(s: R|kotlin/String|, i: R|kotlin/Int|): R|kotlin/Unit| {
}
}
FILE: Test.kt
public final class Tester : R|Inheritor|, R|First| {
public constructor(): R|Tester| {
super<R|Inheritor|>()
}
public final fun test(): R|kotlin/Unit| {
(this@R|/Tester|, this@R|/Tester|).R|/Inheritor.foo|(String(abc), Int(456))
}
}
@@ -0,0 +1,21 @@
// FILE: Base.kt
interface Base {
val x: Int
}
// FILE: Inheritor.java
public class Inheritor implements Base {
public int getX() {
return 42;
}
}
// FILE: Test.kt
class Tester : Inheritor() {
fun test(): Int {
return x
}
}
@@ -0,0 +1,17 @@
FILE: Base.kt
public abstract interface Base : R|kotlin/Any| {
public abstract val x: R|kotlin/Int|
public get(): R|kotlin/Int|
}
FILE: Test.kt
public final class Tester : R|Inheritor| {
public constructor(): R|Tester| {
super<R|Inheritor|>()
}
public final fun test(): R|kotlin/Int| {
^test this@R|/Tester|.R|/Inheritor.x|
}
}
@@ -0,0 +1,17 @@
// FILE: Derived.kt
class Derived : Some()
// FILE: Some.java
public class Some implements Strange {
public Object foo() {
return "";
}
}
// FILE: Strange.kt
interface Strange<out T> {
fun foo(): T
}
@@ -0,0 +1,12 @@
FILE: Derived.kt
public final class Derived : R|Some| {
public constructor(): R|Derived| {
super<R|Some|>()
}
}
FILE: Strange.kt
public abstract interface Strange<out T> : R|kotlin/Any| {
public abstract fun foo(): R|T|
}
@@ -0,0 +1,9 @@
// FILE: JavaClass.java
class JavaClass {
public String getFoo() { return null; }
}
// FILE: test.kt
val x = JavaClass().foo
@@ -0,0 +1,3 @@
FILE: test.kt
public final val x: R|ft<kotlin/String, kotlin/String?>!| = R|/JavaClass.JavaClass|().R|/JavaClass.foo|
public get(): R|ft<kotlin/String, kotlin/String?>!|
@@ -0,0 +1,23 @@
// FILE: A.java
public class A {
public A foo() {
return this;
}
public A bar() {
return this;
}
}
// FILE: test.kt
class B : A() {
override fun foo(): B = this
fun bar(): B = this // Here we should have "missing override" but no ambiguity
fun test() {
foo()
bar()
}
}
@@ -0,0 +1,20 @@
FILE: test.kt
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
public final override fun foo(): R|B| {
^foo this@R|/B|
}
public final fun bar(): R|B| {
^bar this@R|/B|
}
public final fun test(): R|kotlin/Unit| {
this@R|/B|.R|/B.foo|()
this@R|/B|.R|/B.bar|()
}
}
@@ -0,0 +1,18 @@
// MODULE: m1
// FILE: base.kt
package hello
class Hello(val msg: String)
class Test(val set: java.util.Set<*>)
// MODULE: m2(m1)
// FILE: user.kt
package test
import hello.Hello
fun foo(hello: Hello): String = hello.msg
@@ -0,0 +1,23 @@
FILE: base.kt
public final class Hello : R|kotlin/Any| {
public constructor(msg: R|kotlin/String|): R|hello/Hello| {
super<R|kotlin/Any|>()
}
public final val msg: R|kotlin/String| = R|<local>/msg|
public get(): R|kotlin/String|
}
public final class Test : R|kotlin/Any| {
public constructor(set: R|java/util/Set<*>|): R|hello/Test| {
super<R|kotlin/Any|>()
}
public final val set: R|java/util/Set<*>| = R|<local>/set|
public get(): R|java/util/Set<*>|
}
FILE: user.kt
public final fun foo(hello: R|hello/Hello|): R|kotlin/String| {
^foo R|<local>/hello|.R|hello/Hello.msg|
}
@@ -0,0 +1,31 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A<T>() {
open fun foo(arg: T)
}
open class B : A<String>() {
// Fake: override fun foo(arg: String) = super.foo(arg)
// Fake (JVM only): override fun bar(arg: String): String = super.bar(arg)
}
open class C : B() {
open fun bar(arg: String): String = arg
open fun baz(arg: CharSequence): String = arg.toString()
}
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual open class A<T> {
actual open fun foo(arg: T) {}
open fun bar(arg: T): T = arg
open fun baz(arg: T): T = arg
}
class D : C() {
fun test() {
foo("")
bar("") // should be resolved to just C.bar
baz("")
}
}
@@ -0,0 +1,59 @@
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|FakeOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|FakeOverride</B.baz: R|kotlin/String|>|(String())
}
}
@@ -0,0 +1,39 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect class MyList {
fun get(i: Int): Int
}
open class Wrapper(val list: MyList)
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual class MyList {
actual fun get(i: Int): Int = i
fun set(i: Int, v: Int) {}
}
class DerivedList : MyList() {
fun useMember() {
get(1)
set(2, 3)
}
}
fun useList(list: MyList) {
// We should deal with receiver to resolve this
list.get(1)
list.set(2, 3)
}
class DerivedWrapper : Wrapper(MyList()) {
fun use() {
// We should deal with receiver to resolve this
list.get(1)
list.set(2, 3)
}
}
@@ -0,0 +1,58 @@
FILE: common.kt
public final expect class MyList : R|kotlin/Any| {
public constructor(): R|MyList| {
super<R|kotlin/Any|>()
}
public final fun get(i: R|kotlin/Int|): R|kotlin/Int|
}
public open class Wrapper : R|kotlin/Any| {
public constructor(list: R|MyList|): R|Wrapper| {
super<R|kotlin/Any|>()
}
public final val list: R|MyList| = R|<local>/list|
public get(): R|MyList|
}
FILE: jvm.kt
public final actual class MyList : R|kotlin/Any| {
public constructor(): R|MyList| {
super<R|kotlin/Any|>()
}
public final actual fun get(i: R|kotlin/Int|): R|kotlin/Int| {
^get R|<local>/i|
}
public final fun set(i: R|kotlin/Int|, v: R|kotlin/Int|): R|kotlin/Unit| {
}
}
public final class DerivedList : R|MyList| {
public constructor(): R|DerivedList| {
super<R|MyList|>()
}
public final fun useMember(): R|kotlin/Unit| {
this@R|/DerivedList|.R|/MyList.get|(Int(1))
this@R|/DerivedList|.R|/MyList.set|(Int(2), Int(3))
}
}
public final fun useList(list: R|MyList|): R|kotlin/Unit| {
R|<local>/list|.R|/MyList.get|(Int(1))
R|<local>/list|.R|/MyList.set|(Int(2), Int(3))
}
public final class DerivedWrapper : R|Wrapper| {
public constructor(): R|DerivedWrapper| {
super<R|Wrapper|>(R|/MyList.MyList|())
}
public final fun use(): R|kotlin/Unit| {
this@R|/DerivedWrapper|.R|/Wrapper.list|.R|/MyList.get|(Int(1))
this@R|/DerivedWrapper|.R|/Wrapper.list|.R|/MyList.set|(Int(2), Int(3))
}
}
@@ -0,0 +1,32 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A() {
fun foo()
}
open class B : A()
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
actual open class A {
actual fun foo() {}
fun bar() {}
}
class C : B() {
fun test() {
foo()
bar()
}
}
class D : A() {
fun test() {
foo()
bar()
}
}
@@ -0,0 +1,50 @@
FILE: common.kt
public open expect class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit|
}
public open class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
FILE: jvm.kt
public open actual class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final actual fun foo(): R|kotlin/Unit| {
}
public final fun bar(): R|kotlin/Unit| {
}
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/C|.R|/A.foo|()
this@R|/C|.R|/A.bar|()
}
}
public final class D : R|A| {
public constructor(): R|D| {
super<R|A|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|/A.foo|()
this@R|/D|.R|/A.bar|()
}
}
@@ -0,0 +1,40 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A() {
fun foo()
}
open class B : A()
// MODULE: m1-jvm(m1-common)
// FILE: jvm.kt
abstract class X {
fun bar() {}
}
interface Y {
fun baz() {}
}
actual open class A : X(), Y {
actual fun foo() {}
}
class C : B() {
fun test() {
foo()
bar()
baz()
}
}
class D : A() {
fun test() {
foo()
bar()
baz()
}
}
@@ -0,0 +1,63 @@
FILE: common.kt
public open expect class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit|
}
public open class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
FILE: jvm.kt
public abstract class X : R|kotlin/Any| {
public constructor(): R|X| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
}
}
public abstract interface Y : R|kotlin/Any| {
public open fun baz(): R|kotlin/Unit| {
}
}
public open actual class A : R|X|, R|Y| {
public constructor(): R|A| {
super<R|X|>()
}
public final actual fun foo(): R|kotlin/Unit| {
}
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/C|.R|/A.foo|()
this@R|/C|.R|/X.bar|()
this@R|/C|.R|/Y.baz|()
}
}
public final class D : R|A| {
public constructor(): R|D| {
super<R|A|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|/A.foo|()
this@R|/D|.R|/X.bar|()
this@R|/D|.R|/Y.baz|()
}
}