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|()
}
}