[FIR-TEST] Move analysis tests to separate module

This commit is contained in:
Dmitriy Novozhilov
2020-03-18 15:10:46 +03:00
parent 3a479d5d16
commit cc07ae96b3
1477 changed files with 1001 additions and 980 deletions
@@ -0,0 +1,27 @@
import kotlin.reflect.KProperty
class FreezableVar<T>(private var value: T) {
operator fun getValue(thisRef: Any, property: KProperty<*>): T = value
operator fun setValue(thisRef: Any, property: KProperty<*>, value: T) {
this.value = value
}
}
class LocalFreezableVar<T>(private var value: T) {
operator fun getValue(thisRef: Nothing?, property: KProperty<*>): T = value
operator fun setValue(thisRef: Nothing?, property: KProperty<*>, value: T) {
this.value = value
}
}
class Test {
var x: Boolean by FreezableVar(true)
var y by FreezableVar("")
}
fun test() {
var x: Boolean by LocalFreezableVar(true)
var y by LocalFreezableVar("")
}
@@ -0,0 +1,63 @@
FILE: delegateInference.kt
public final class FreezableVar<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|FreezableVar<T>| {
super<R|kotlin/Any|>()
}
private final var value: R|T| = R|<local>/value|
private get(): R|T|
private set(value: R|T|): R|kotlin/Unit|
public final operator fun getValue(thisRef: R|kotlin/Any|, property: R|kotlin/reflect/KProperty<*>|): R|T| {
^getValue this@R|/FreezableVar|.R|/FreezableVar.value|
}
public final operator fun setValue(thisRef: R|kotlin/Any|, property: R|kotlin/reflect/KProperty<*>|, value: R|T|): R|kotlin/Unit| {
this@R|/FreezableVar|.R|/FreezableVar.value| = R|<local>/value|
}
}
public final class LocalFreezableVar<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|LocalFreezableVar<T>| {
super<R|kotlin/Any|>()
}
private final var value: R|T| = R|<local>/value|
private get(): R|T|
private set(value: R|T|): R|kotlin/Unit|
public final operator fun getValue(thisRef: R|kotlin/Nothing?|, property: R|kotlin/reflect/KProperty<*>|): R|T| {
^getValue this@R|/LocalFreezableVar|.R|/LocalFreezableVar.value|
}
public final operator fun setValue(thisRef: R|kotlin/Nothing?|, property: R|kotlin/reflect/KProperty<*>|, value: R|T|): R|kotlin/Unit| {
this@R|/LocalFreezableVar|.R|/LocalFreezableVar.value| = R|<local>/value|
}
}
public final class Test : R|kotlin/Any| {
public constructor(): R|Test| {
super<R|kotlin/Any|>()
}
public final var x: R|kotlin/Boolean|by R|/FreezableVar.FreezableVar|<R|kotlin/Boolean|>(Boolean(true))
public get(): R|kotlin/Boolean| {
^ D|/Test.x|.R|FakeOverride</FreezableVar.getValue: R|kotlin/Boolean|>|(this@R|/Test|, ::R|/Test.x|)
}
public set(<set-?>: R|kotlin/Boolean|): R|kotlin/Unit| {
D|/Test.x|.R|FakeOverride</FreezableVar.setValue: R|kotlin/Unit|>|(this@R|/Test|, ::R|/Test.x|, R|<local>/x|)
}
public final var y: R|kotlin/String|by R|/FreezableVar.FreezableVar|<R|kotlin/String|>(String())
public get(): R|kotlin/String| {
^ D|/Test.y|.R|FakeOverride</FreezableVar.getValue: R|kotlin/String|>|(this@R|/Test|, ::R|/Test.y|)
}
public set(<set-?>: R|kotlin/String|): R|kotlin/Unit| {
D|/Test.y|.R|FakeOverride</FreezableVar.setValue: R|kotlin/Unit|>|(this@R|/Test|, ::R|/Test.y|, R|<local>/y|)
}
}
public final fun test(): R|kotlin/Unit| {
lvar x: R|kotlin/Boolean|by R|/LocalFreezableVar.LocalFreezableVar|<R|kotlin/Boolean|>(Boolean(true))
lvar y: R|kotlin/String|by R|/LocalFreezableVar.LocalFreezableVar|<R|kotlin/String|>(String())
}
@@ -0,0 +1,16 @@
import kotlin.reflect.KProperty
class LazyDelegate<T>(val value: T) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value
}
fun <T> lazy(block: () -> T): LazyDelegate<T> = LazyDelegate(block())
fun getAny(): Any? = null
class Test {
val x by lazy {
val y = getAny() as? String ?: ""
y
}
}
@@ -0,0 +1,43 @@
FILE: delegateWithLambda.kt
public final class LazyDelegate<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|LazyDelegate<T>| {
super<R|kotlin/Any|>()
}
public final val value: R|T| = R|<local>/value|
public get(): R|T|
public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|T| {
^getValue this@R|/LazyDelegate|.R|/LazyDelegate.value|
}
}
public final fun <T> lazy(block: R|() -> T|): R|LazyDelegate<T>| {
^lazy R|/LazyDelegate.LazyDelegate|<R|T|>(R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|())
}
public final fun getAny(): R|kotlin/Any?| {
^getAny Null(null)
}
public final class Test : R|kotlin/Any| {
public constructor(): R|Test| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/String|by R|/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| {
lval y: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = (R|/getAny|() as? R|kotlin/String|)) {
==($subj$, Null(null)) -> {
String()
}
else -> {
R|<local>/<elvis>|
}
}
^ R|<local>/y|
}
)
public get(): R|kotlin/String| {
^ D|/Test.x|.R|FakeOverride</LazyDelegate.getValue: R|kotlin/String|>|(this@R|/Test|, ::R|/Test.x|)
}
}
@@ -0,0 +1,8 @@
inline fun <L> runLogged(action: () -> L): L {
return action()
}
operator fun <V> V.getValue(receiver: Any?, p: Any): V =
runLogged { this }
val testK by runLogged { "K" }
@@ -0,0 +1,17 @@
FILE: extensionGenericGetValue.kt
public final inline fun <L> runLogged(action: R|() -> L|): R|L| {
^runLogged R|<local>/action|.R|FakeOverride<kotlin/Function0.invoke: R|L|>|()
}
public final operator fun <V> R|V|.getValue(receiver: R|kotlin/Any?|, p: R|kotlin/Any|): R|V| {
^getValue R|/runLogged|<R|V|>(<L> = runLogged@fun <anonymous>(): R|V| <kind=UNKNOWN> {
^ this@R|/getValue|
}
)
}
public final val testK: R|kotlin/String|by R|/runLogged|<R|kotlin/String|>(<L> = runLogged@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
^ String(K)
}
)
public get(): R|kotlin/String| {
^ D|/testK|.R|/getValue|<R|kotlin/String|>(Null(null), ::R|/testK|)
}
@@ -0,0 +1,8 @@
inline fun <L> runLogged(action: () -> L): L {
return action()
}
operator fun String.getValue(receiver: Any?, p: Any): String =
runLogged { this }
val testK by runLogged { "K" }
@@ -0,0 +1,17 @@
FILE: extensionGetValueWithTypeVariableAsReceiver.kt
public final inline fun <L> runLogged(action: R|() -> L|): R|L| {
^runLogged R|<local>/action|.R|FakeOverride<kotlin/Function0.invoke: R|L|>|()
}
public final operator fun R|kotlin/String|.getValue(receiver: R|kotlin/Any?|, p: R|kotlin/Any|): R|kotlin/String| {
^getValue R|/runLogged|<R|kotlin/String|>(<L> = runLogged@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
^ this@R|/getValue|
}
)
}
public final val testK: R|kotlin/String|by R|/runLogged|<R|kotlin/String|>(<L> = runLogged@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
^ String(K)
}
)
public get(): R|kotlin/String| {
^ D|/testK|.R|/getValue|(Null(null), ::R|/testK|)
}
@@ -0,0 +1,19 @@
import kotlin.reflect.KProperty
class Delegate<T>(var value: T) {
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = value
operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) {
value = newValue
}
}
class DelegateProvider<T>(val value: T) {
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): Delegate<T> = Delegate(value)
}
fun <T> delegate(value: T): DelegateProvider<T> = DelegateProvider(value)
class A {
val x by delegate(1)
}
@@ -0,0 +1,46 @@
FILE: provideDelegate.kt
public final class Delegate<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|Delegate<T>| {
super<R|kotlin/Any|>()
}
public final var value: R|T| = R|<local>/value|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|T| {
^getValue this@R|/Delegate|.R|/Delegate.value|
}
public final operator fun setValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|, newValue: R|T|): R|kotlin/Unit| {
this@R|/Delegate|.R|/Delegate.value| = R|<local>/newValue|
}
}
public final class DelegateProvider<T> : R|kotlin/Any| {
public constructor<T>(value: R|T|): R|DelegateProvider<T>| {
super<R|kotlin/Any|>()
}
public final val value: R|T| = R|<local>/value|
public get(): R|T|
public final operator fun provideDelegate(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|Delegate<T>| {
^provideDelegate R|/Delegate.Delegate|<R|T|>(this@R|/DelegateProvider|.R|/DelegateProvider.value|)
}
}
public final fun <T> delegate(value: R|T|): R|DelegateProvider<T>| {
^delegate R|/DelegateProvider.DelegateProvider|<R|T|>(R|<local>/value|)
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int|by R|/delegate|<R|kotlin/Int|>(Int(1)).R|FakeOverride</DelegateProvider.provideDelegate: R|Delegate<kotlin/Int>|>|(this@R|/A|, ::R|/A.x|)
public get(): R|kotlin/Int| {
^ D|/A.x|.R|FakeOverride</Delegate.getValue: R|kotlin/Int|>|(this@R|/A|, ::R|/A.x|)
}
}