[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,10 @@
interface Foo {
fun bar(): Int
}
val x by lazy {
val foo = object : Foo {
override fun bar(): Int = 42
}
foo.bar()
}
@@ -0,0 +1,23 @@
FILE: anonymousInDelegate.kt
public abstract interface Foo : R|kotlin/Any| {
public abstract fun bar(): R|kotlin/Int|
}
public final val x: R|kotlin/Int|by R|kotlin/lazy|<R|kotlin/Int|>(<L> = lazy@fun <anonymous>(): R|kotlin/Int| {
lval foo: R|anonymous| = object : R|Foo| {
private constructor(): R|anonymous| {
super<R|kotlin/Any|>()
}
public final override fun bar(): R|kotlin/Int| {
^bar Int(42)
}
}
^ R|<local>/foo|.R|/anonymous.bar|()
}
)
public get(): R|kotlin/Int| {
^ D|/x|.R|kotlin/getValue|<R|kotlin/Int|>(Null(null), ::R|/x|)
}
@@ -0,0 +1,26 @@
import kotlin.properties.Delegates
import kotlin.properties.ReadWriteProperty
interface ClassifierNamePolicy {
object SOURCE_CODE_QUALIFIED : ClassifierNamePolicy
}
interface KotlinType
class A(val isLocked: Boolean) {
private fun <T> property(initialValue: T): ReadWriteProperty<A, T> {
return Delegates.vetoable(initialValue) { _, _, _ ->
if (isLocked) {
throw IllegalStateException("Cannot modify readonly DescriptorRendererOptions")
}
else {
true
}
}
}
var classifierNamePolicy: ClassifierNamePolicy by property(ClassifierNamePolicy.SOURCE_CODE_QUALIFIED)
// getter has INAPPLICABLE diagnostic, see dump
var typeNormalizer by property<(KotlinType) -> KotlinType>({ it })
}
@@ -0,0 +1,55 @@
FILE: delegateTypeMismatch.kt
public abstract interface ClassifierNamePolicy : R|kotlin/Any| {
public final object SOURCE_CODE_QUALIFIED : R|ClassifierNamePolicy| {
private constructor(): R|ClassifierNamePolicy.SOURCE_CODE_QUALIFIED| {
super<R|kotlin/Any|>()
}
}
}
public abstract interface KotlinType : R|kotlin/Any| {
}
public final class A : R|kotlin/Any| {
public constructor(isLocked: R|kotlin/Boolean|): R|A| {
super<R|kotlin/Any|>()
}
public final val isLocked: R|kotlin/Boolean| = R|<local>/isLocked|
public get(): R|kotlin/Boolean|
private final fun <T> property(initialValue: R|T|): R|kotlin/properties/ReadWriteProperty<A, T>| {
^property Q|kotlin/properties/Delegates|.R|kotlin/properties/Delegates.vetoable|<R|T|>(R|<local>/initialValue|, <L> = vetoable@fun <anonymous>(_: R|kotlin/reflect/KProperty<*>|, _: R|T|, _: R|T|): R|kotlin/Boolean| <kind=UNKNOWN> {
^ when () {
this@R|/A|.R|/A.isLocked| -> {
throw R|java/lang/IllegalStateException.IllegalStateException|(String(Cannot modify readonly DescriptorRendererOptions))
}
else -> {
Boolean(true)
}
}
}
)
}
public final var classifierNamePolicy: R|ClassifierNamePolicy|by this@R|/A|.R|/A.property|<R|ClassifierNamePolicy|>(Q|ClassifierNamePolicy.SOURCE_CODE_QUALIFIED|)
public get(): R|ClassifierNamePolicy| {
^ D|/A.classifierNamePolicy|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|ClassifierNamePolicy|>|(this@R|/A|, ::R|/A.classifierNamePolicy|)
}
public set(<set-?>: R|ClassifierNamePolicy|): R|kotlin/Unit| {
D|/A.classifierNamePolicy|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/A|, ::R|/A.classifierNamePolicy|, R|<local>/classifierNamePolicy|)
}
public final var typeNormalizer: R|(KotlinType) -> KotlinType|by this@R|/A|.R|/A.property|<R|(KotlinType) -> KotlinType|>(property@fun <anonymous>(it: R|KotlinType|): R|KotlinType| {
^ R|<local>/it|
}
)
public get(): R|(KotlinType) -> KotlinType| {
^ D|/A.typeNormalizer|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|(KotlinType) -> KotlinType|>|(this@R|/A|, ::R|/A.typeNormalizer|)
}
public set(<set-?>: R|(KotlinType) -> KotlinType|): R|kotlin/Unit| {
D|/A.typeNormalizer|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/A|, ::R|/A.typeNormalizer|, R|<local>/typeNormalizer|)
}
}
@@ -0,0 +1,178 @@
digraph delegateWithAnonymousObject_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function <init>" style="filled" fillcolor=red];
1 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
2 [label="Exit function <init>" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
subgraph cluster_1 {
color=red
3 [label="Enter function delegate" style="filled" fillcolor=red];
4 [label="Const: Null(null)"];
5 [label="Check not null: Null(null)!!"];
6 [label="Jump: ^delegate Null(null)!!"];
7 [label="Stub" style="filled" fillcolor=gray];
8 [label="Exit function delegate" style="filled" fillcolor=red];
}
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {8};
6 -> {7} [style=dotted];
7 -> {8} [style=dotted];
subgraph cluster_2 {
color=red
9 [label="Enter function <init>" style="filled" fillcolor=red];
10 [label="Delegated constructor call: super<R|DelegateProvider<IssueListView>|>()"];
11 [label="Exit function <init>" style="filled" fillcolor=red];
}
9 -> {10};
10 -> {11};
subgraph cluster_3 {
color=red
12 [label="Enter function updateFrom" style="filled" fillcolor=red];
13 [label="Exit function updateFrom" style="filled" fillcolor=red];
}
12 -> {13};
subgraph cluster_4 {
color=red
14 [label="Enter function <init>" style="filled" fillcolor=red];
15 [label="Delegated constructor call: super<R|DelegateProvider<IssuesListUserProfile>|>()"];
16 [label="Exit function <init>" style="filled" fillcolor=red];
}
14 -> {15};
15 -> {16};
subgraph cluster_5 {
color=red
17 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
18 [label="Exit anonymous object"];
19 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
17 -> {18};
18 -> {19};
subgraph cluster_6 {
color=red
20 [label="Enter function <init>" style="filled" fillcolor=red];
21 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
22 [label="Exit function <init>" style="filled" fillcolor=red];
}
20 -> {21};
21 -> {22};
subgraph cluster_7 {
color=red
23 [label="Enter function getValue" style="filled" fillcolor=red];
24 [label="Function call: R|/IssueListView.IssueListView|()"];
25 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
26 [label="Stub" style="filled" fillcolor=gray];
27 [label="Exit function getValue" style="filled" fillcolor=red];
}
23 -> {24};
24 -> {25};
25 -> {27};
25 -> {26} [style=dotted];
26 -> {27} [style=dotted];
subgraph cluster_8 {
color=red
28 [label="Enter function setValue" style="filled" fillcolor=red];
29 [label="Function call: R|/IssueListView.IssueListView|()"];
30 [label="Access variable R|<local>/value|"];
31 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"];
32 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
33 [label="Stub" style="filled" fillcolor=gray];
34 [label="Exit function setValue" style="filled" fillcolor=red];
}
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {34};
32 -> {33} [style=dotted];
33 -> {34} [style=dotted];
subgraph cluster_9 {
color=red
35 [label="Enter function getter" style="filled" fillcolor=red];
36 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
37 [label="Access variable this@R|/IssuesListUserProfile|"];
38 [label="Function call: D|/IssuesListUserProfile.issueListView|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(...)"];
39 [label="Jump: ^ D|/IssuesListUserProfile.issueListView|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"];
40 [label="Stub" style="filled" fillcolor=gray];
41 [label="Exit function getter" style="filled" fillcolor=red];
}
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {41};
39 -> {40} [style=dotted];
40 -> {41} [style=dotted];
subgraph cluster_10 {
color=red
42 [label="Enter function setter" style="filled" fillcolor=red];
43 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
44 [label="Access variable this@R|/IssuesListUserProfile|"];
45 [label="Access variable R|<local>/issueListView|"];
46 [label="Function call: D|/IssuesListUserProfile.issueListView|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)"];
47 [label="Exit function setter" style="filled" fillcolor=red];
}
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
subgraph cluster_11 {
color=red
48 [label="Enter property" style="filled" fillcolor=red];
49 [label="Postponed enter to lambda"];
50 [label="Postponed exit from lambda"];
51 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
52 [label="Access variable this@R|/IssuesListUserProfile|"];
53 [label="Access variable this@R|/IssuesListUserProfile|"];
54 [label="Access variable this@R|/IssuesListUserProfile|"];
55 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)"];
56 [label="Postponed enter to lambda"];
57 [label="Postponed exit from lambda"];
58 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
59 [label="Exit property" style="filled" fillcolor=red];
}
48 -> {49};
49 -> {50 50} [color=green];
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57 57} [color=green];
57 -> {58};
58 -> {59};
}
@@ -0,0 +1,28 @@
// !DUMP_CFG
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
abstract class DelegateProvider<in Type>
fun <Type : Base, Base : DelegateProvider<Base>, Target : Any> Type.delegate(
factory: () -> ReadWriteProperty<Type, Target>
): ReadWriteProperty<Type, Target> = null!!
class IssueListView : DelegateProvider<IssueListView>() {
fun updateFrom(any: Any) {}
}
class IssuesListUserProfile : DelegateProvider<IssuesListUserProfile>() {
var issueListView by delegate {
object : ReadWriteProperty<IssuesListUserProfile, IssueListView> {
override fun getValue(thisRef: IssuesListUserProfile, property: KProperty<*>): IssueListView {
return IssueListView()
}
override fun setValue(thisRef: IssuesListUserProfile, property: KProperty<*>, value: IssueListView) {
return IssueListView().updateFrom(value)
}
}
}
}
@@ -0,0 +1,50 @@
FILE: delegateWithAnonymousObject.kt
public abstract class DelegateProvider<in Type> : R|kotlin/Any| {
public constructor<in Type>(): R|DelegateProvider<Type>| {
super<R|kotlin/Any|>()
}
}
public final fun <Type : R|Base|, Base : R|DelegateProvider<Base>|, Target : R|kotlin/Any|> R|Type|.delegate(factory: R|() -> kotlin/properties/ReadWriteProperty<Type, Target>|): R|kotlin/properties/ReadWriteProperty<Type, Target>| {
^delegate Null(null)!!
}
public final class IssueListView : R|DelegateProvider<IssueListView>| {
public constructor(): R|IssueListView| {
super<R|DelegateProvider<IssueListView>|>()
}
public final fun updateFrom(any: R|kotlin/Any|): R|kotlin/Unit| {
}
}
public final class IssuesListUserProfile : R|DelegateProvider<IssuesListUserProfile>| {
public constructor(): R|IssuesListUserProfile| {
super<R|DelegateProvider<IssuesListUserProfile>|>()
}
public final var issueListView: R|IssueListView|by this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(<L> = delegate@fun <anonymous>(): R|kotlin/properties/ReadWriteProperty<IssuesListUserProfile, IssueListView>| {
^ object : R|kotlin/properties/ReadWriteProperty<IssuesListUserProfile, IssueListView>| {
private constructor(): R|anonymous| {
super<R|kotlin/Any|>()
}
public final override fun getValue(thisRef: R|IssuesListUserProfile|, property: R|kotlin/reflect/KProperty<*>|): R|IssueListView| {
^getValue R|/IssueListView.IssueListView|()
}
public final override fun setValue(thisRef: R|IssuesListUserProfile|, property: R|kotlin/reflect/KProperty<*>|, value: R|IssueListView|): R|kotlin/Unit| {
^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)
}
}
}
)
public get(): R|IssueListView| {
^ D|/IssuesListUserProfile.issueListView|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)
}
public set(<set-?>: R|IssueListView|): R|kotlin/Unit| {
D|/IssuesListUserProfile.issueListView|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|, R|<local>/issueListView|)
}
}
@@ -0,0 +1,12 @@
// ISSUE: KT-37304
import kotlin.properties.ReadWriteProperty
interface B
class A {
private fun <T> property(initialValue: T): ReadWriteProperty<A, T> = null!!
var conventer by property<(B) -> B>({ it })
var conventerWithExpectedType: (B) -> B by property({ it })
}
@@ -0,0 +1,35 @@
FILE: propertyWithFunctionalType.kt
public abstract interface B : R|kotlin/Any| {
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
private final fun <T> property(initialValue: R|T|): R|kotlin/properties/ReadWriteProperty<A, T>| {
^property Null(null)!!
}
public final var conventer: R|(B) -> B|by this@R|/A|.R|/A.property|<R|(B) -> B|>(property@fun <anonymous>(it: R|B|): R|B| {
^ R|<local>/it|
}
)
public get(): R|(B) -> B| {
^ D|/A.conventer|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|(B) -> B|>|(this@R|/A|, ::R|/A.conventer|)
}
public set(<set-?>: R|(B) -> B|): R|kotlin/Unit| {
D|/A.conventer|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/A|, ::R|/A.conventer|, R|<local>/conventer|)
}
public final var conventerWithExpectedType: R|(B) -> B|by this@R|/A|.R|/A.property|<R|(B) -> B|>(property@fun <anonymous>(it: R|B|): R|B| {
^ R|<local>/it|
}
)
public get(): R|(B) -> B| {
^ D|/A.conventerWithExpectedType|.R|FakeOverride<kotlin/properties/ReadWriteProperty.getValue: R|(B) -> B|>|(this@R|/A|, ::R|/A.conventerWithExpectedType|)
}
public set(<set-?>: R|(B) -> B|): R|kotlin/Unit| {
D|/A.conventerWithExpectedType|.R|FakeOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/A|, ::R|/A.conventerWithExpectedType|, R|<local>/conventerWithExpectedType|)
}
}
@@ -0,0 +1,9 @@
class Delegate(val value: String) {
operator fun getValue(thisRef: Any?, property: Any?) = value
}
class DelegateProvider(val value: String) {
operator fun provideDelegate(thisRef: Any?, property: Any?) = Delegate(value)
}
val testTopLevel by DelegateProvider("OK")
@@ -0,0 +1,31 @@
FILE: simpleDelegateProvider.kt
public final class Delegate : R|kotlin/Any| {
public constructor(value: R|kotlin/String|): R|Delegate| {
super<R|kotlin/Any|>()
}
public final val value: R|kotlin/String| = R|<local>/value|
public get(): R|kotlin/String|
public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/Any?|): R|kotlin/String| {
^getValue this@R|/Delegate|.R|/Delegate.value|
}
}
public final class DelegateProvider : R|kotlin/Any| {
public constructor(value: R|kotlin/String|): R|DelegateProvider| {
super<R|kotlin/Any|>()
}
public final val value: R|kotlin/String| = R|<local>/value|
public get(): R|kotlin/String|
public final operator fun provideDelegate(thisRef: R|kotlin/Any?|, property: R|kotlin/Any?|): R|Delegate| {
^provideDelegate R|/Delegate.Delegate|(this@R|/DelegateProvider|.R|/DelegateProvider.value|)
}
}
public final val testTopLevel: R|kotlin/String|by R|/DelegateProvider.DelegateProvider|(String(OK)).R|/DelegateProvider.provideDelegate|(Null(null), ::R|/testTopLevel|)
public get(): R|kotlin/String| {
^ D|/testTopLevel|.R|/Delegate.getValue|(Null(null), ::R|/testTopLevel|)
}
@@ -0,0 +1,5 @@
class C(val map: MutableMap<String, Any>) {
var foo by map
}
var bar by hashMapOf<String, Any>()
@@ -0,0 +1,25 @@
FILE: simpleDelegatedToMap.kt
public final class C : R|kotlin/Any| {
public constructor(map: R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>|): R|C| {
super<R|kotlin/Any|>()
}
public final val map: R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>| = R|<local>/map|
public get(): R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>|
public final var foo: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>by R|<local>/map|
public get(): <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]> {
^ D|/C.foo|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(this@R|/C|, ::R|/C.foo|)
}
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
D|/C.foo|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(this@R|/C|, ::R|/C.foo|, R|<local>/foo|)
}
}
public final var bar: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>by R|kotlin/collections/hashMapOf|<R|kotlin/String|, R|kotlin/Any|>()
public get(): <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]> {
^ D|/bar|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(Null(null), ::R|/bar|)
}
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
D|/bar|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(Null(null), ::R|/bar|, R|<local>/bar|)
}