[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
fun String.k(): () -> String = { -> this }
|
||||
|
||||
fun test() = "hello".k()()
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FILE: doubleBrackets.kt
|
||||
public final fun R|kotlin/String|.k(): R|() -> kotlin/String| {
|
||||
^k fun <anonymous>(): R|kotlin/String| {
|
||||
^ this@R|/k|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/String| {
|
||||
^test String(hello).R|/k|().R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
fun x() {
|
||||
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
val x: Foo = Foo()
|
||||
|
||||
operator fun invoke(): Foo { return this }
|
||||
|
||||
fun bar() = x() // Should resolve to invoke
|
||||
}
|
||||
|
||||
class Bar {
|
||||
fun x() {}
|
||||
|
||||
val x: Bar = Bar()
|
||||
|
||||
operator fun invoke(): Bar { return this }
|
||||
|
||||
fun baz() {
|
||||
x() // Should resolve to fun x()
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
FILE: explicitReceiver.kt
|
||||
public final fun x(): R|kotlin/Unit| {
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|Foo| = R|/Foo.Foo|()
|
||||
public get(): R|Foo|
|
||||
|
||||
public final operator fun invoke(): R|Foo| {
|
||||
^invoke this@R|/Foo|
|
||||
}
|
||||
|
||||
public final fun bar(): R|Foo| {
|
||||
^bar this@R|/Foo|.R|/Foo.x|.R|/Foo.invoke|()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun x(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final val x: R|Bar| = R|/Bar.Bar|()
|
||||
public get(): R|Bar|
|
||||
|
||||
public final operator fun invoke(): R|Bar| {
|
||||
^invoke this@R|/Bar|
|
||||
}
|
||||
|
||||
public final fun baz(): R|kotlin/Unit| {
|
||||
this@R|/Bar|.R|/Bar.x|()
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
class Bar {
|
||||
operator fun invoke(): Foo { return this }
|
||||
|
||||
}
|
||||
|
||||
fun x() {
|
||||
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
operator fun Bar.invoke(): Foo { return this }
|
||||
|
||||
val x: Bar = Bar()
|
||||
|
||||
fun bar() = x() // Should resolve to invoke
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
FILE: explicitReceiver2.kt
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(): R|Foo| {
|
||||
^invoke this@R|/Bar|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun x(): R|kotlin/Unit| {
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun R|Bar|.invoke(): R|Foo| {
|
||||
^invoke this@R|/Foo.invoke|
|
||||
}
|
||||
|
||||
public final val x: R|Bar| = R|/Bar.Bar|()
|
||||
public get(): R|Bar|
|
||||
|
||||
public final fun bar(): R|Foo| {
|
||||
^bar this@R|/Foo|.R|/Foo.x|.R|/Bar.invoke|()
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
fun x() {}
|
||||
|
||||
class Foo {
|
||||
operator fun Int.invoke(): Foo = this@Foo
|
||||
|
||||
val x = 0
|
||||
|
||||
fun foo() = x() // should resolve to invoke
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
FILE: extension.kt
|
||||
public final fun x(): R|kotlin/Unit| {
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun R|kotlin/Int|.invoke(): R|Foo| {
|
||||
^invoke this@R|/Foo|
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = Int(0)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
public final fun foo(): R|Foo| {
|
||||
^foo (this@R|/Foo|, this@R|/Foo|.R|/Foo.x|).R|/Foo.invoke|()
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
object X
|
||||
|
||||
class Y {
|
||||
fun f(op: X.() -> Unit) {
|
||||
X.op()
|
||||
|
||||
val x = X
|
||||
x.op()
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
FILE: extensionOnObject.kt
|
||||
public final object X : R|kotlin/Any| {
|
||||
private constructor(): R|X| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Y : R|kotlin/Any| {
|
||||
public constructor(): R|Y| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun f(op: R|X.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|<local>/op|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(Q|X|)
|
||||
lval x: R|X| = Q|X|
|
||||
R|<local>/op|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/x|)
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun bar(doIt: Int.() -> Int) {
|
||||
val i: Int? = 1
|
||||
i?.<!INAPPLICABLE_CANDIDATE!>doIt<!>()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
FILE: extensionSafeCall.kt
|
||||
public final fun bar(doIt: R|kotlin/Int.() -> kotlin/Int|): R|kotlin/Unit| {
|
||||
lval i: R|kotlin/Int?| = Int(1)
|
||||
R|<local>/i|?.<Inapplicable(INAPPLICABLE): [kotlin/Function1.invoke]>#()
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
fun x() {}
|
||||
|
||||
operator fun Int.invoke(): Foo = this@Foo
|
||||
|
||||
class Foo {
|
||||
|
||||
val x = 0
|
||||
|
||||
fun foo() = x() // should resolve to fun x
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
FILE: farInvokeExtension.kt
|
||||
public final fun x(): R|kotlin/Unit| {
|
||||
}
|
||||
public final operator fun R|kotlin/Int|.invoke(): R|Foo| {
|
||||
^invoke this@Foo#
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = Int(0)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
^foo R|/x|()
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
class A {
|
||||
fun bar() = foo() // should resolve to invoke
|
||||
|
||||
fun invoke() = this
|
||||
}
|
||||
|
||||
fun create() = A()
|
||||
|
||||
val foo = create()
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
FILE: implicitTypeOrder.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|A| {
|
||||
^bar R|/foo|.R|/A.invoke|()
|
||||
}
|
||||
|
||||
public final fun invoke(): R|A| {
|
||||
^invoke this@R|/A|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun create(): R|A| {
|
||||
^create R|/A.A|()
|
||||
}
|
||||
public final val foo: R|A| = R|/create|()
|
||||
public get(): R|A|
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun test(e: Int.() -> String) {
|
||||
val s = 3.e()
|
||||
val ss = 3.(e)()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
FILE: inBrackets.kt
|
||||
public final fun test(e: R|kotlin/Int.() -> kotlin/String|): R|kotlin/Unit| {
|
||||
lval s: R|kotlin/String| = R|<local>/e|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/String|>|(Int(3))
|
||||
lval ss: R|kotlin/String| = R|<local>/e|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/String|>|(Int(3))
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
operator fun String.invoke() = this
|
||||
|
||||
val some = ""
|
||||
fun sss() {
|
||||
val some = 10
|
||||
|
||||
// Should be resolved to top-level some,
|
||||
// because with local some invoke isn't applicable
|
||||
some()
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
FILE: incorrectInvokeReceiver.kt
|
||||
public final operator fun R|kotlin/String|.invoke(): R|kotlin/String| {
|
||||
^invoke this@R|/invoke|
|
||||
}
|
||||
public final val some: R|kotlin/String| = String()
|
||||
public get(): R|kotlin/String|
|
||||
public final fun sss(): R|kotlin/Unit| {
|
||||
lval some: R|kotlin/Int| = Int(10)
|
||||
R|/some|.R|/invoke|()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Bar(name: () -> String) {
|
||||
val name = name()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FILE: propertyFromParameter.kt
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(name: R|() -> kotlin/String|): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val name: R|kotlin/String| = R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
class A(val x: (String.() -> Unit)?, val y: (String.() -> Int))
|
||||
|
||||
fun test(a: A) {
|
||||
if (a.x != null) {
|
||||
val b = a.x
|
||||
"".b()
|
||||
}
|
||||
val c = a.y
|
||||
val d = "".c()
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
FILE: propertyWithExtensionType.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/String.() -> kotlin/Unit|, y: R|kotlin/String.() -> kotlin/Int|): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/String.() -> kotlin/Unit| = R|<local>/x|
|
||||
public get(): R|kotlin/String.() -> kotlin/Unit|
|
||||
|
||||
public final val y: R|kotlin/String.() -> kotlin/Int| = R|<local>/y|
|
||||
public get(): R|kotlin/String.() -> kotlin/Int|
|
||||
|
||||
}
|
||||
public final fun test(a: R|A|): R|kotlin/Unit| {
|
||||
when () {
|
||||
!=(R|<local>/a|.R|/A.x|, Null(null)) -> {
|
||||
lval b: R|kotlin/String.() -> kotlin/Unit| = R|<local>/a|.R|/A.x|
|
||||
R|<local>/b|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(String())
|
||||
}
|
||||
}
|
||||
|
||||
lval c: R|kotlin/String.() -> kotlin/Int| = R|<local>/a|.R|/A.y|
|
||||
lval d: R|kotlin/Int| = R|<local>/c|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|(String())
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Simple {
|
||||
operator fun invoke(): String = "invoke"
|
||||
}
|
||||
|
||||
fun test(s: Simple) {
|
||||
val result = s()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
FILE: simple.kt
|
||||
public final class Simple : R|kotlin/Any| {
|
||||
public constructor(): R|Simple| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(): R|kotlin/String| {
|
||||
^invoke String(invoke)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(s: R|Simple|): R|kotlin/Unit| {
|
||||
lval result: R|kotlin/String| = R|<local>/s|.R|/Simple.invoke|()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
class Bar {
|
||||
fun FooBar.invoke(): Bar = this
|
||||
}
|
||||
|
||||
class Buz
|
||||
|
||||
class FooBar
|
||||
|
||||
class Foo {
|
||||
val Buz.foobar: Bar get() = Bar()
|
||||
|
||||
fun FooBar.chk(buz: Buz) {
|
||||
// NB: really this example is unresolvable (in old FE too)
|
||||
// local/buz is extension receiver of foobar
|
||||
// this@Foo is dispatch receiver of foobar
|
||||
// Foo/foobar is dispatch receiver of invoke
|
||||
// this@chk is extension receiver of invoke
|
||||
buz.<!UNRESOLVED_REFERENCE!>foobar<!>()
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
FILE: threeReceivers.kt
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun R|FooBar|.invoke(): R|Bar| {
|
||||
^invoke this@R|/Bar.invoke|
|
||||
}
|
||||
|
||||
}
|
||||
public final class Buz : R|kotlin/Any| {
|
||||
public constructor(): R|Buz| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class FooBar : R|kotlin/Any| {
|
||||
public constructor(): R|FooBar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val R|Buz|.foobar: R|Bar|
|
||||
public get(): R|Bar| {
|
||||
^ R|/Bar.Bar|()
|
||||
}
|
||||
|
||||
public final fun R|FooBar|.chk(buz: R|Buz|): R|kotlin/Unit| {
|
||||
R|<local>/buz|.<Unresolved name: foobar>#()
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
class C
|
||||
|
||||
class B
|
||||
|
||||
class A {
|
||||
val B.foo: C.() -> Unit get() = null
|
||||
}
|
||||
|
||||
fun <T, R> with(arg: T, f: T.() -> R): R = arg.f()
|
||||
|
||||
fun test(a: A, b: B, c: C) {
|
||||
with(a) {
|
||||
with(c) {
|
||||
b.foo(c)
|
||||
// [this@a,b].foo.invoke(c)
|
||||
}
|
||||
with(b) {
|
||||
c.foo()
|
||||
// [this@a,this@b].foo.invoke(c)
|
||||
with(c) {
|
||||
foo()
|
||||
// [this@a,this@b].foo.invoke(this@c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
FILE: threeReceiversCorrect.kt
|
||||
public final class C : R|kotlin/Any| {
|
||||
public constructor(): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val R|B|.foo: R|C.() -> kotlin/Unit|
|
||||
public get(): R|C.() -> kotlin/Unit| {
|
||||
^ Null(null)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <T, R> with(arg: R|T|, f: R|T.() -> R|): R|R| {
|
||||
^with R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|R|>|(R|<local>/arg|)
|
||||
}
|
||||
public final fun test(a: R|A|, b: R|B|, c: R|C|): R|kotlin/Unit| {
|
||||
R|/with|<R|A|, R|kotlin/Unit|>(R|<local>/a|, <L> = with@fun R|A|.<anonymous>(): R|kotlin/Unit| {
|
||||
R|/with|<R|C|, R|kotlin/Unit|>(R|<local>/c|, <L> = with@fun R|C|.<anonymous>(): R|kotlin/Unit| {
|
||||
(this@R|special/anonymous|, R|<local>/b|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|)
|
||||
}
|
||||
)
|
||||
^ R|/with|<R|B|, R|kotlin/Unit|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/c|)
|
||||
^ R|/with|<R|C|, R|kotlin/Unit|>(R|<local>/c|, <L> = with@fun R|C|.<anonymous>(): R|kotlin/Unit| {
|
||||
(this@R|special/anonymous|, this@R|special/anonymous|).R|/A.foo|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(this@R|special/anonymous|)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user