FIR IDE: move analysis api fir testdata to the analysis directory

This commit is contained in:
Ilya Kirillov
2021-09-14 17:22:32 +02:00
parent 4d52b354af
commit 42f0536904
705 changed files with 0 additions and 0 deletions
@@ -0,0 +1,9 @@
class Base(
val p1: Int
)
class Sub(
override val p1: Int
) : Base(p1) {
constructor(i : Int, j : Int) : <expr>super(i + j)</expr>
}
@@ -0,0 +1,4 @@
KtDelegatedConstructorCall:
argumentMapping = { i + j -> (p1: kotlin.Int) }
targetFunction = <constructor>(p1: kotlin.Int): Base
kind = SUPER_CALL
@@ -0,0 +1,9 @@
class Base(
val p1: Int
)
class Sub(
p: Int
) : Base(p), Unresolved {
constructor(s: String) : <expr>super(s)</expr>
}
@@ -0,0 +1,4 @@
KtDelegatedConstructorCall:
argumentMapping = { s -> (p1: kotlin.Int) }
targetFunction = ERR<Argument type mismatch: actual type is kotlin/String but kotlin/Int was expected, [<constructor>(p1: kotlin.Int): Base]>
kind = SUPER_CALL
@@ -0,0 +1,9 @@
class Base(
val p1: Int
)
class Sub(
override val p1: Int
) : Base(p1) {
constructor(s: String) : <expr>this(s.length)</expr>
}
@@ -0,0 +1,4 @@
KtDelegatedConstructorCall:
argumentMapping = { s.length -> (p1: kotlin.Int) }
targetFunction = <constructor>(p1: kotlin.Int): Sub
kind = THIS_CALL
@@ -0,0 +1,9 @@
class Base(
val p1: Int
)
class Sub(
p: Int
) : Base(p), Unresolved {
constructor(i : Int, j : Int) : <expr>this(i, j, i * j)</expr>
}
@@ -0,0 +1,4 @@
KtDelegatedConstructorCall:
argumentMapping = { }
targetFunction = ERR<None of the following functions are applicable: [/Sub.Sub, /Sub.Sub], [<constructor>(p: kotlin.Int): Sub, <constructor>(i: kotlin.Int, j: kotlin.Int): Sub]>
kind = THIS_CALL
@@ -0,0 +1,5 @@
fun function(a: Int) {}
fun call() {
<expr>function(1)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int) }
targetFunction = /function(a: kotlin.Int): kotlin.Unit
@@ -0,0 +1,5 @@
fun function(a: Int, b: (String) -> Boolean) {}
fun call() {
<expr>function(1) { s -> true }</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), { s -> true } -> (b: kotlin.Function1<kotlin.String, kotlin.Boolean>) }
targetFunction = /function(a: kotlin.Int, b: kotlin.Function1<kotlin.String, kotlin.Boolean>): kotlin.Unit
@@ -0,0 +1,5 @@
fun function(a: Int, b: String) {}
fun call() {
<expr>function(b = "foo", a = 1)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { "foo" -> (b: kotlin.String), 1 -> (a: kotlin.Int) }
targetFunction = /function(a: kotlin.Int, b: kotlin.String): kotlin.Unit
@@ -0,0 +1,5 @@
fun function(a: Int, b: (String) -> Boolean) {}
fun call() {
<expr>function(1, { s -> true })</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), { s -> true } -> (b: kotlin.Function1<kotlin.String, kotlin.Boolean>) }
targetFunction = /function(a: kotlin.Int, b: kotlin.Function1<kotlin.String, kotlin.Boolean>): kotlin.Unit
@@ -0,0 +1,6 @@
fun function(vararg a: Int) {}
fun call() {
val args = intArrayOf(1, 2, 3)
<expr>function(*args)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { args -> (vararg a: kotlin.Int) }
targetFunction = /function(vararg a: kotlin.Int): kotlin.Unit
@@ -0,0 +1,5 @@
fun function(vararg a: Int) {}
fun call() {
<expr>function(1, 2, 3)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (vararg a: kotlin.Int), 2 -> (vararg a: kotlin.Int), 3 -> (vararg a: kotlin.Int) }
targetFunction = /function(vararg a: kotlin.Int): kotlin.Unit
@@ -0,0 +1,5 @@
fun String.function(a: Int) {}
fun call() {
"str".<expr>function(1)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int) }
targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
@@ -0,0 +1,5 @@
fun String.function(a: Int) {}
fun call() {
"str"?.<expr>function(1)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int) }
targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
@@ -0,0 +1,7 @@
class A {
constructor(i: Int)
}
fun call() {
val a = <expr>A(42)</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 42 -> (i: kotlin.Int) }
targetFunction = <constructor>(i: kotlin.Int): A
@@ -0,0 +1,5 @@
class A
fun call() {
val a = <expr>A()</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = <constructor>(): A
@@ -0,0 +1,7 @@
// FILE: call.kt
fun call() {
val a = <expr>A()</expr>
}
// FILE: A.java
class A {}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = <constructor>(): A
@@ -0,0 +1,7 @@
class C {
operator fun get(a: Int, b: String): Boolean = true
}
fun call(c: C) {
val res = <expr>c[1, "foo"]</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String) }
targetFunction = /C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean
@@ -0,0 +1,7 @@
class C {
operator fun get(a: Int, b: String): Boolean = true
}
fun call(c: C) {
val res = <expr>c[1]</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int) }
targetFunction = ERR<No value passed for parameter 'b', [/C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean]>
@@ -0,0 +1,7 @@
class C {
operator fun get(a: Int, b: String): Boolean = true
}
fun call(c: C) {
val res = <expr>c[1, "foo", false]</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String) }
targetFunction = ERR<Too many arguments for public final operator fun /C.get(a: R|kotlin/Int|, b: R|kotlin/String|): R|kotlin/Boolean|, [/C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean]>
@@ -0,0 +1,7 @@
class C {
operator fun set(a: Int, b: String, value: Boolean) {}
}
fun call(c: C) {
<expr>c[1, "foo"]</expr> = false
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String), false -> (value: kotlin.Boolean) }
targetFunction = /C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit
@@ -0,0 +1,7 @@
class C {
operator fun set(a: Int, b: String, value: Boolean) {}
}
fun call(c: C) {
<expr>c[1]</expr> = false
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), false -> (value: kotlin.Boolean) }
targetFunction = ERR<No value passed for parameter 'b', [/C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit]>
@@ -0,0 +1,7 @@
class C {
operator fun set(a: Int, b: String, value: Boolean) {}
}
fun call(c: C) {
<expr>c[1, "foo", 3.14]</expr> = false
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String), false -> (value: kotlin.Boolean) }
targetFunction = ERR<Too many arguments for public final operator fun /C.set(a: R|kotlin/Int|, b: R|kotlin/String|, value: R|kotlin/Boolean|): R|kotlin/Unit|, [/C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit]>
@@ -0,0 +1,10 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
javaClass.<expr>javaMethod()</expr>
}
// FILE: JavaClass.java
class JavaClass {
void javaMethod() {}
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = /JavaClass.javaMethod(): kotlin.Unit
@@ -0,0 +1,10 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
javaClass.<expr>foo</expr>
}
// FILE: JavaClass.java
class JavaClass {
int getFoo() { return 42; }
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = /JavaClass.getFoo(): kotlin.Int
@@ -0,0 +1,18 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
javaClass.<expr>sub</expr>.foo = 42
}
// FILE: JavaClass.java
class JavaClass {
private JavaSubClass instance = new JavaSubClass();
JavaSubClass getSub() { return instance; }
}
// FILE: JavaSubClass.java
class JavaSubClass {
private int foo = -1;
int getFoo() { return foo; }
void setFoo(int v) { foo = v; }
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = /JavaClass.getSub(): ft<JavaSubClass, JavaSubClass?>
@@ -0,0 +1,12 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
javaClass.<expr>foo</expr> = 42
}
// FILE: JavaClass.java
class JavaClass {
private int foo = -1;
int getFoo() { return foo; }
void setFoo(int v) { foo = v; }
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 42 -> (v: kotlin.Int) }
targetFunction = /JavaClass.setFoo(v: kotlin.Int): kotlin.Unit
@@ -0,0 +1,13 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
// Intentionally incomplete to see if `foo` refers to `setFoo`.
javaClass.<expr>foo</expr> =
}
// FILE: JavaClass.java
class JavaClass {
private int foo = -1;
int getFoo() { return foo; }
void setFoo(int v) { foo = v; }
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = ERR<Setter value is missing, [/JavaClass.setFoo(v: kotlin.Int): kotlin.Unit]>
@@ -0,0 +1,9 @@
fun call {
val ktClass = KtClass()
ktClass.<expr>foo</expr>
}
class KtClass {
val foo: Int
get() = 42
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = <getter>(): kotlin.Int
@@ -0,0 +1,13 @@
fun call() {
val ktClass = KtClass()
ktClass.<expr>instance</expr>.foo = 42
}
class KtClass {
val instance : KtSubClass = KtSubClass()
}
class KtSubClass {
var foo : Int = -1
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = <getter>(): KtSubClass
@@ -0,0 +1,8 @@
fun call {
val ktClass = KtClass()
ktClass.<expr>foo</expr> = 42
}
class KtClass {
var foo : Int = -1
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 42 -> (value: kotlin.Int) }
targetFunction = <setter>(value: kotlin.Int): kotlin.Unit
@@ -0,0 +1,5 @@
infix fun <A, B> A.to(other: B) = this
open class A<T>(x: T)
class B : A(<expr>1 to 2</expr>)
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { 2 -> (other: B) }
targetFunction = /to(<receiver>: A, other: B): A
@@ -0,0 +1,5 @@
fun x() {
<expr>foo(1)</expr>
}
fun foo(){}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = ERR<Too many arguments for public final fun /foo(): R|kotlin/Unit|, [/foo(): kotlin.Unit]>
@@ -0,0 +1,5 @@
interface I
class A(
p : Int
) : I, <expr>Unresolved(p)</expr>
@@ -0,0 +1,4 @@
KtDelegatedConstructorCall:
argumentMapping = { }
targetFunction = ERR<Unresolved reference: Unresolved, []>
kind = SUPER_CALL
@@ -0,0 +1,3 @@
fun call(x: (Int) -> String) {
<expr>x(1)</expr>
}
@@ -0,0 +1,4 @@
KtFunctionalTypeVariableCall:
target = x: kotlin.Function1<kotlin.Int, kotlin.String>
argumentMapping = { 1 -> (p1: kotlin.Int) }
targetFunction = kotlin/Function1.invoke(p1: kotlin.Int): kotlin.String
@@ -0,0 +1,5 @@
operator fun Int.invoke(): String {}
fun call(x: kotlin.int) {
<expr>x()</expr>
}
@@ -0,0 +1,3 @@
KtFunctionCall:
argumentMapping = { }
targetFunction = /invoke(<receiver>: kotlin.Int): kotlin.String
@@ -0,0 +1,4 @@
open class A
class B : A
@@ -0,0 +1,2 @@
open class A
class B : A
@@ -0,0 +1,2 @@
open class A
class B : A
@@ -0,0 +1,9 @@
abstract class A {
abstract class Nested
}
typealias TA = A
class B : TA() {
class NestedInB : Nested()
}
@@ -0,0 +1,7 @@
abstract class A {
abstract class Nested
}
typealias TA = A
class B : TA {
class NestedInB : A.Nested
}
@@ -0,0 +1,7 @@
abstract class A {
abstract class Nested
}
typealias TA = A
class B : TA {
class NestedInB : A.Nested
}
@@ -0,0 +1,13 @@
package p
abstract class My {
abstract class NestedOne : My() {
abstract class NestedTwo : NestedOne() {
}
}
}
class Your : My() {
class NestedThree : NestedOne()
}
@@ -0,0 +1,8 @@
abstract class My {
abstract class NestedOne : My {
abstract class NestedTwo : My.NestedOne
}
}
class Your : My {
class NestedThree : My.NestedOne
}
@@ -0,0 +1,8 @@
abstract class My {
abstract class NestedOne : My {
abstract class NestedTwo : My.NestedOne
}
}
class Your : My {
class NestedThree : My.NestedOne
}
@@ -0,0 +1,20 @@
@Target(AnnotationTarget.ANNOTATION_CLASS) annotation class base
@base annotation class derived
@base class correct(@base val x: Int) {
@base constructor(): this(0)
}
@base enum class My {
@base FIRST,
@base SECOND
}
@base fun foo(@base y: @base Int): Int {
@base fun bar(@base z: @base Int) = z + 1
@base val local = bar(y)
return local
}
@base val z = 0
@@ -0,0 +1,16 @@
@Target(allowedTargets = NOT_CONST_EXPRESSION) annotation class base
@base annotation class derived
@base class correct {
constructor(@base x: Int)
@base val x: Int
@base constructor()
}
@base enum class My {
FIRST,
SECOND,
}
@base fun foo(@base y: @base Int): Int {
@base fun bar(@base z: @base Int): Int
@base val local: Int
}
@base val z: Int
@@ -0,0 +1,16 @@
@Target(allowedTargets = NOT_CONST_EXPRESSION) annotation class base
@base annotation class derived
@base class correct {
constructor(@base x: Int)
@base val x: Int
@base constructor()
}
@base enum class My {
FIRST,
SECOND,
}
@base fun foo(@base y: @base Int): Int {
@base fun bar(@base z: @base Int): Int
@base val local: Int
}
@base val z: Int
@@ -0,0 +1,11 @@
package a.b
class C<T, out S> {
inner class D<R, in P> {
}
}
interface Test {
val x: a.b.C<out CharSequence, *>.D<in List<*>, *>
}
@@ -0,0 +1,6 @@
class C<T, out S> {
inner class D<R, in P>
}
interface Test {
val x: C<out CharSequence, *>.D<in List<*>, *>
}
@@ -0,0 +1,6 @@
class C<T, out S> {
inner class D<R, in P>
}
interface Test {
val x: C<out CharSequence, *>.D<in List<*>, *>
}
@@ -0,0 +1,20 @@
object A {
constructor()
init {}
}
enum class B {
X() {
constructor()
}
}
class C {
companion object {
constructor()
}
}
val anonObject = object {
constructor()
}
@@ -0,0 +1,12 @@
object A {
constructor()
}
enum class B {
X,
}
class C {
companion object {
constructor()
}
}
val anonObject: Any
@@ -0,0 +1,12 @@
object A {
constructor()
}
enum class B {
X,
}
class C {
companion object {
constructor()
}
}
val anonObject: Any
@@ -0,0 +1,10 @@
interface IFace<T> {
fun getStatus(arg: T): Boolean
}
class Some
private fun resolve(): IFace<Some> {
return object : IFace<Some> {
override fun getStatus(arg: Some) = true
}
}
@@ -0,0 +1,10 @@
interface IFace<T> {
fun getStatus(arg: T): Boolean
}
class Some
private fun resolve(): IFace<Some> {
object : IFace<Some> {
constructor()
override fun getStatus(arg: Some): Boolean
}
}
@@ -0,0 +1,10 @@
interface IFace<T> {
fun getStatus(arg: T): Boolean
}
class Some
private fun resolve(): IFace<Some> {
object : IFace<Some> {
constructor()
override fun getStatus(arg: Some): Boolean
}
}
@@ -0,0 +1,19 @@
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KCallable
import kotlin.reflect.KProperty
public interface MyRwProperty<in T, V> {
public operator fun setValue(thisRef: T, property: Any, value: V)
public operator fun getValue(thisRef: T, property: Any): V
}
val x: Int by lazy { 1 + 2 }
val delegate = object: MyRwProperty<Any?, Int> {
override fun getValue(thisRef: Any?, property: Any): Int = 1
override fun setValue(thisRef: Any?, property: Any, value: Int) {}
}
val value by delegate
var variable by delegate
@@ -0,0 +1,12 @@
interface MyRwProperty<in T, V> {
operator fun setValue(thisRef: T, property: Any, value: V)
operator fun getValue(thisRef: T, property: Any): V
}
val x: Int
get()
val delegate: MyRwProperty<Any?, Int>
val value: Int
get()
var variable: Int
get()
set(value: Int)
@@ -0,0 +1,12 @@
interface MyRwProperty<in T, V> {
operator fun setValue(thisRef: T, property: Any, value: V)
operator fun getValue(thisRef: T, property: Any): V
}
val x: Int
get()
val delegate: MyRwProperty<Any?, Int>
val value: Int
get()
var variable: Int
get()
set(value: Int)
@@ -0,0 +1,5 @@
open class Base<T>(val x: T)
class Derived<T : Any>(x: T) : Base<T>(x)
fun <T : Any> create(x: T): Derived<T> = Derived(x)
@@ -0,0 +1,8 @@
open class Base<T> {
constructor(x: T)
val x: T
}
class Derived<T : Any> : Base<T> {
constructor(x: T)
}
fun <T : Any> create(x: T): Derived<T>
@@ -0,0 +1,8 @@
open class Base<T> {
constructor(x: T)
val x: T
}
class Derived<T : Any> : Base<T> {
constructor(x: T)
}
fun <T : Any> create(x: T): Derived<T>
@@ -0,0 +1,4 @@
fun test() {
val x = object {}
}
@@ -0,0 +1,3 @@
fun test() {
val x: Any
}
@@ -0,0 +1,3 @@
fun test() {
val x: Any
}
@@ -0,0 +1,46 @@
import my.println
enum class Order {
FIRST,
SECOND,
THIRD
}
enum class Planet(val m: Double, internal val r: Double) {
MERCURY(1.0, 2.0) {
override fun sayHello() {
println("Hello!!!")
}
},
VENERA(3.0, 4.0) {
override fun sayHello() {
println("Ola!!!")
}
},
EARTH(5.0, 6.0) {
override fun sayHello() {
println("Privet!!!")
}
};
val g: Double = G * m / (r * r)
abstract fun sayHello()
companion object {
const val G = 6.67e-11
}
}
enum class PseudoInsn(val signature: String = "()V") {
FIX_STACK_BEFORE_JUMP,
FAKE_ALWAYS_TRUE_IFEQ("()I"),
FAKE_ALWAYS_FALSE_IFEQ("()I"),
SAVE_STACK_BEFORE_TRY,
RESTORE_STACK_IN_TRY_CATCH,
STORE_NOT_NULL,
AS_NOT_NULL("(Ljava/lang/Object;)Ljava/lang/Object;")
;
fun emit() {}
}
@@ -0,0 +1,30 @@
enum class Order {
FIRST,
SECOND,
THIRD,
}
enum class Planet {
MERCURY,
VENERA,
EARTH,
constructor(m: Double, r: Double)
val m: Double
internal val r: Double
val g: Double
abstract fun sayHello()
companion object {
const val G: Double
}
}
enum class PseudoInsn {
FIX_STACK_BEFORE_JUMP,
FAKE_ALWAYS_TRUE_IFEQ,
FAKE_ALWAYS_FALSE_IFEQ,
SAVE_STACK_BEFORE_TRY,
RESTORE_STACK_IN_TRY_CATCH,
STORE_NOT_NULL,
AS_NOT_NULL,
constructor(signature: String = ...)
val signature: String
fun emit()
}

Some files were not shown because too many files have changed in this diff Show More