[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// FILE: MyFunction.java
|
||||
public interface MyFunction<T, R> {
|
||||
R foo(T x);
|
||||
}
|
||||
|
||||
// FILE: JavaUsage.java
|
||||
|
||||
public class JavaUsage {
|
||||
public static void foo1(MyFunction<Integer, String> x) {}
|
||||
public static void foo2(MyFunction<? super Number, ? extends CharSequence> x) {}
|
||||
public static <X, Y> Y foo3(MyFunction<X, Y> f, X x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
|
||||
fun main() {
|
||||
JavaUsage.foo1 { x ->
|
||||
x.toInt().toString()
|
||||
}
|
||||
|
||||
JavaUsage.foo2 { x ->
|
||||
x.toInt().toString()
|
||||
}
|
||||
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo2<!> { x: Int ->
|
||||
x.toString()
|
||||
}
|
||||
|
||||
JavaUsage.foo3(
|
||||
{ x ->
|
||||
(x + 1).toString()
|
||||
},
|
||||
1
|
||||
)
|
||||
|
||||
JavaUsage.foo3(
|
||||
{ x: Number ->
|
||||
x.toInt().toString()
|
||||
},
|
||||
2
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
FILE: main.kt
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaUsage|.R|/JavaUsage.foo1|(<L> = foo1@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|ft<kotlin/String, kotlin/String?>!| {
|
||||
^ R|<local>/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|()
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.R|/JavaUsage.foo2|(<L> = foo2@fun <anonymous>(x: R|ft<kotlin/Number, kotlin/Number?>!|): R|ft<kotlin/CharSequence, kotlin/CharSequence?>!| {
|
||||
^ R|<local>/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|()
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.<Inapplicable(INAPPLICABLE): [/JavaUsage.foo2]>#(<L> = foo2@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
||||
^ R|<local>/x|.R|kotlin/Any.toString|()
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
||||
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
|
||||
}
|
||||
, Int(1))
|
||||
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|kotlin/Number|): R|kotlin/String| {
|
||||
^ R|<local>/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|()
|
||||
}
|
||||
, Int(2))
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// TODO: These interfaces must be marked as "fun" ones that modifier is supported
|
||||
interface MyRunnable {
|
||||
fun foo(x: Int): Boolean
|
||||
}
|
||||
|
||||
interface WithProperty {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
interface TwoAbstract : MyRunnable {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
interface Super {
|
||||
fun foo(x: Int): Any
|
||||
}
|
||||
|
||||
interface Derived : Super {
|
||||
override fun foo(x: Int): Boolean
|
||||
}
|
||||
|
||||
fun foo1(m: MyRunnable) {}
|
||||
fun foo2(m: WithProperty) {}
|
||||
fun foo3(m: TwoAbstract) {}
|
||||
fun foo4(m: Derived) {}
|
||||
|
||||
fun main() {
|
||||
val f = { t: Int -> t > 1}
|
||||
|
||||
foo1 { x -> x > 1 }
|
||||
foo1(f)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!> { x -> x <!UNRESOLVED_REFERENCE!>><!> 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(f)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo3<!> { x -> x <!UNRESOLVED_REFERENCE!>><!> 1 }
|
||||
<!INAPPLICABLE_CANDIDATE!>foo3<!>(f)
|
||||
|
||||
foo4 { x -> x > 1 }
|
||||
foo4(f)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
FILE: kotlinSam.kt
|
||||
public abstract interface MyRunnable : R|kotlin/Any| {
|
||||
public abstract fun foo(x: R|kotlin/Int|): R|kotlin/Boolean|
|
||||
|
||||
}
|
||||
public abstract interface WithProperty : R|kotlin/Any| {
|
||||
public abstract val x: R|kotlin/Int|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
public abstract interface TwoAbstract : R|MyRunnable| {
|
||||
public abstract fun bar(): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public abstract interface Super : R|kotlin/Any| {
|
||||
public abstract fun foo(x: R|kotlin/Int|): R|kotlin/Any|
|
||||
|
||||
}
|
||||
public abstract interface Derived : R|Super| {
|
||||
public abstract override fun foo(x: R|kotlin/Int|): R|kotlin/Boolean|
|
||||
|
||||
}
|
||||
public final fun foo1(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun foo2(m: R|WithProperty|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun foo3(m: R|TwoAbstract|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun foo4(m: R|Derived|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
lval f: R|(kotlin/Int) -> kotlin/Boolean| = fun <anonymous>(t: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/t|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
|
||||
R|/foo1|(<L> = foo1@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
R|/foo1|(R|<local>/f|)
|
||||
<Inapplicable(INAPPLICABLE): [/foo2]>#(<L> = foo2@fun <anonymous>(x: R|ERROR CLASS: No type for parameter|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.<Unresolved name: compareTo>#(Int(1)))
|
||||
}
|
||||
)
|
||||
<Inapplicable(INAPPLICABLE): [/foo2]>#(R|<local>/f|)
|
||||
<Inapplicable(INAPPLICABLE): [/foo3]>#(<L> = foo3@fun <anonymous>(x: R|ERROR CLASS: No type for parameter|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.<Unresolved name: compareTo>#(Int(1)))
|
||||
}
|
||||
)
|
||||
<Inapplicable(INAPPLICABLE): [/foo3]>#(R|<local>/f|)
|
||||
R|/foo4|(<L> = foo4@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
R|/foo4|(R|<local>/f|)
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: MyRunnable.java
|
||||
public interface MyRunnable {
|
||||
void bar();
|
||||
}
|
||||
|
||||
// FILE: DerivedRunnable.java
|
||||
public interface DerivedRunnable extends MyRunnable {
|
||||
boolean foo(int x);
|
||||
}
|
||||
|
||||
// FILE: JavaUsage.java
|
||||
|
||||
public class JavaUsage {
|
||||
public static void foo(DerivedRunnable x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(m: MyRunnable) {}
|
||||
|
||||
fun main() {
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!> {
|
||||
x ->
|
||||
x <!UNRESOLVED_REFERENCE!>><!> 1
|
||||
}
|
||||
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> <!UNRESOLVED_REFERENCE!>><!> 1 })
|
||||
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
JavaUsage.<!INAPPLICABLE_CANDIDATE!>foo<!>(x)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
FILE: main.kt
|
||||
public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaUsage|.<Inapplicable(INAPPLICABLE): [/JavaUsage.foo]>#(<L> = foo@fun <anonymous>(x: R|ERROR CLASS: No type for parameter|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.<Unresolved name: compareTo>#(Int(1)))
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.<Inapplicable(INAPPLICABLE): [/JavaUsage.foo]>#(foo@fun <anonymous>(): R|kotlin/Boolean| {
|
||||
^ CMP(>, <Unresolved name: it>#.<Unresolved name: compareTo>#(Int(1)))
|
||||
}
|
||||
)
|
||||
lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
|
||||
Q|JavaUsage|.<Inapplicable(INAPPLICABLE): [/JavaUsage.foo]>#(R|<local>/x|)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public static void foo(Runnable x) {}
|
||||
public void bar(Runnable x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main() {
|
||||
JavaClass.foo {
|
||||
""
|
||||
}
|
||||
|
||||
JavaClass().bar {
|
||||
""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
FILE: main.kt
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaClass|.R|/JavaClass.foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
|
||||
^ String()
|
||||
}
|
||||
)
|
||||
R|/JavaClass.JavaClass|().R|/JavaClass.bar|(<L> = bar@fun <anonymous>(): R|kotlin/Unit| {
|
||||
^ String()
|
||||
}
|
||||
)
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// FILE: Condition.java
|
||||
|
||||
public interface Condition {
|
||||
boolean value(boolean t);
|
||||
}
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public Foo(Condition filter) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test() {
|
||||
Foo { it }
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
FILE: main.kt
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/Foo.Foo|(<L> = Foo@fun <anonymous>(it: R|kotlin/Boolean|): R|kotlin/Boolean| {
|
||||
^ R|<local>/it|
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// FILE: MyRunnable.java
|
||||
public interface MyRunnable {
|
||||
boolean foo(int x);
|
||||
default void bar() {}
|
||||
}
|
||||
|
||||
// FILE: DerivedRunnable.java
|
||||
public interface DerivedRunnable extends MyRunnable {
|
||||
default void baz() {}
|
||||
}
|
||||
|
||||
// FILE: JavaUsage.java
|
||||
|
||||
public class JavaUsage {
|
||||
public static void foo(DerivedRunnable x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(m: MyRunnable) {}
|
||||
|
||||
fun main() {
|
||||
JavaUsage.foo {
|
||||
x ->
|
||||
x > 1
|
||||
}
|
||||
|
||||
JavaUsage.foo({ it > 1 })
|
||||
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
JavaUsage.foo(x)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
FILE: main.kt
|
||||
public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(<L> = foo@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/it|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(R|<local>/x|)
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// FILE: MyRunnable.java
|
||||
public interface MyRunnable {
|
||||
Object foo(int x);
|
||||
default void bar() {}
|
||||
}
|
||||
|
||||
// FILE: DerivedRunnable.java
|
||||
public interface DerivedRunnable extends MyRunnable {
|
||||
@Override
|
||||
Boolean foo(int x);
|
||||
default void baz() {}
|
||||
}
|
||||
|
||||
// FILE: JavaUsage.java
|
||||
|
||||
public class JavaUsage {
|
||||
public static void foo(DerivedRunnable x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(m: MyRunnable) {}
|
||||
|
||||
fun main() {
|
||||
JavaUsage.foo {
|
||||
x ->
|
||||
x > 1
|
||||
}
|
||||
|
||||
JavaUsage.foo({ it > 1 })
|
||||
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
JavaUsage.foo(x)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
FILE: main.kt
|
||||
public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(<L> = foo@fun <anonymous>(x: R|kotlin/Int|): R|ft<kotlin/Boolean, kotlin/Boolean?>!| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun <anonymous>(it: R|kotlin/Int|): R|ft<kotlin/Boolean, kotlin/Boolean?>!| {
|
||||
^ CMP(>, R|<local>/it|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(R|<local>/x|)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// IGNORE_LIGHT_TREE
|
||||
// Does not work in light tree mode due to lack of Java element finder there
|
||||
// FILE: KotlinTypeChecker.java
|
||||
|
||||
public interface KotlinTypeChecker {
|
||||
|
||||
interface TypeConstructorEquality {
|
||||
boolean equals(@NotNull TypeConstructor a, @NotNull TypeConstructor b);
|
||||
}
|
||||
|
||||
KotlinTypeChecker DEFAULT = NewKotlinTypeChecker.Companion.getDefault();
|
||||
|
||||
boolean isSubtypeOf(@NotNull KotlinType subtype, @NotNull KotlinType supertype);
|
||||
boolean equalTypes(@NotNull KotlinType a, @NotNull KotlinType b);
|
||||
}
|
||||
|
||||
// FILE: OverridingUtil.java
|
||||
public class OverridingUtil {
|
||||
public static OverridingUtil createWithEqualityAxioms(@NotNull KotlinTypeChecker.TypeConstructorEquality equalityAxioms) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface TypeConstructor {
|
||||
val x: String
|
||||
}
|
||||
|
||||
fun main() {
|
||||
OverridingUtil.createWithEqualityAxioms l1@{ c1, c2 ->
|
||||
if (c1.x == c2.x) return@l1 true
|
||||
false
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
FILE: main.kt
|
||||
public abstract interface TypeConstructor : R|kotlin/Any| {
|
||||
public abstract val x: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|OverridingUtil|.R|/OverridingUtil.createWithEqualityAxioms|(<L> = l1@fun <anonymous>(c1: R|ft<TypeConstructor, TypeConstructor?>!|, c2: R|ft<TypeConstructor, TypeConstructor?>!|): R|kotlin/Boolean| {
|
||||
when () {
|
||||
==(R|<local>/c1|.R|/TypeConstructor.x|, R|<local>/c2|.R|/TypeConstructor.x|) -> {
|
||||
^@l1 Boolean(true)
|
||||
}
|
||||
}
|
||||
|
||||
^ Boolean(false)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// FILE: MyRunnable.java
|
||||
public interface MyRunnable {
|
||||
boolean foo(int x);
|
||||
}
|
||||
|
||||
// FILE: JavaUsage.java
|
||||
|
||||
public class JavaUsage {
|
||||
public static void foo(MyRunnable x) {}
|
||||
}
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(m: MyRunnable) {}
|
||||
|
||||
fun main() {
|
||||
JavaUsage.foo {
|
||||
x ->
|
||||
x > 1
|
||||
}
|
||||
|
||||
JavaUsage.foo({ it > 1 })
|
||||
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
JavaUsage.foo(x)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
FILE: main.kt
|
||||
public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(<L> = foo@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/it|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
)
|
||||
lval x: R|(kotlin/Int) -> kotlin/Boolean| = fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
}
|
||||
|
||||
Q|JavaUsage|.R|/JavaUsage.foo|(R|<local>/x|)
|
||||
}
|
||||
Reference in New Issue
Block a user