[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,30 @@
package org.jetbrains.kotlin.codegen.range.inExpression
class CallBasedInExpressionGenerator(
val codegen: ExpressionCodegen,
operatorReference: KtSimpleNameExpression
) : InExpressionGenerator {
private val resolvedCall = operatorReference.<!UNRESOLVED_REFERENCE!>getResolvedCallWithAssert<!>(codegen.<!UNRESOLVED_REFERENCE!>bindingContext<!>)
private val isInverted = operatorReference.<!UNRESOLVED_REFERENCE!>getReferencedNameElementType<!>() == <!UNRESOLVED_REFERENCE!>KtTokens<!>.<!UNRESOLVED_REFERENCE!>NOT_IN<!>
override fun generate(argument: StackValue): BranchedValue =
gen(argument).<!INAPPLICABLE_CANDIDATE!>let<!> { if (isInverted) <!UNRESOLVED_REFERENCE!>Invert<!>(<!UNRESOLVED_REFERENCE!>it<!>) else <!UNRESOLVED_REFERENCE!>it<!> }
private fun gen(argument: StackValue): BranchedValue =
object : BranchedValue(argument, null, argument.<!UNRESOLVED_REFERENCE!>type<!>, <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!>) {
override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) {
invokeFunction(v)
<!UNRESOLVED_REFERENCE!>coerceTo<!>(type, kotlinType, v)
}
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
invokeFunction(v)
v.<!UNRESOLVED_REFERENCE!>visitJumpInsn<!>(if (jumpIfFalse) <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFEQ<!> else <!UNRESOLVED_REFERENCE!>Opcodes<!>.<!UNRESOLVED_REFERENCE!>IFNE<!>, jumpLabel)
}
private fun invokeFunction(v: InstructionAdapter) {
val result = codegen.<!UNRESOLVED_REFERENCE!>invokeFunction<!>(resolvedCall.<!UNRESOLVED_REFERENCE!>call<!>, resolvedCall, <!UNRESOLVED_REFERENCE!>none<!>())
result.<!UNRESOLVED_REFERENCE!>put<!>(result.<!UNRESOLVED_REFERENCE!>type<!>, result.<!UNRESOLVED_REFERENCE!>kotlinType<!>, v)
}
}
}
@@ -0,0 +1,64 @@
FILE: CallBasedInExpressionGenerator.kt
public final class CallBasedInExpressionGenerator : R|ERROR CLASS: Symbol not found, for `InExpressionGenerator`| {
public constructor(codegen: R|ERROR CLASS: Symbol not found, for `ExpressionCodegen`|, operatorReference: R|ERROR CLASS: Symbol not found, for `KtSimpleNameExpression`|): R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator| {
super<R|kotlin/Any|>()
}
public final val codegen: R|ERROR CLASS: Symbol not found, for `ExpressionCodegen`| = R|<local>/codegen|
public get(): R|ERROR CLASS: Symbol not found, for `ExpressionCodegen`|
private final val resolvedCall: <ERROR TYPE REF: Unresolved name: getResolvedCallWithAssert> = R|<local>/operatorReference|.<Unresolved name: getResolvedCallWithAssert>#(R|<local>/codegen|.<Unresolved name: bindingContext>#)
private get(): <ERROR TYPE REF: Unresolved name: getResolvedCallWithAssert>
private final val isInverted: R|kotlin/Boolean| = ==(R|<local>/operatorReference|.<Unresolved name: getReferencedNameElementType>#(), <Unresolved name: KtTokens>#.<Unresolved name: NOT_IN>#)
private get(): R|kotlin/Boolean|
public final override fun generate(argument: R|ERROR CLASS: Symbol not found, for `StackValue`|): R|ERROR CLASS: Symbol not found, for `BranchedValue`| {
^generate R?C|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.gen|(R|<local>/argument|).<Inapplicable(WRONG_RECEIVER): [kotlin/let]>#(<L> = let@fun <anonymous>(): R|ERROR CLASS: Can't resolve when expression| {
^ when () {
this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.isInverted| -> {
<Unresolved name: Invert>#(<Unresolved name: it>#)
}
else -> {
<Unresolved name: it>#
}
}
}
)
}
private final fun gen(argument: R|ERROR CLASS: Symbol not found, for `StackValue`|): R|ERROR CLASS: Symbol not found, for `BranchedValue`| {
^gen object : R|ERROR CLASS: Symbol not found, for `BranchedValue`| {
private constructor(): R|anonymous| {
super<R|ERROR CLASS: Symbol not found, for `BranchedValue`|>(R|<local>/argument|, Null(null), R|<local>/argument|.<Unresolved name: type>#, <Unresolved name: Opcodes>#.<Unresolved name: IFEQ>#)
}
public final override fun putSelector(type: R|ERROR CLASS: Symbol not found, for `Type`|, kotlinType: R|ERROR CLASS: Symbol not found, for `KotlinType?`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
this@R|/anonymous|.R|/anonymous.invokeFunction|(R|<local>/v|)
<Unresolved name: coerceTo>#(R|<local>/type|, R|<local>/kotlinType|, R|<local>/v|)
}
public final override fun condJump(jumpLabel: R|ERROR CLASS: Symbol not found, for `Label`|, v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|, jumpIfFalse: R|kotlin/Boolean|): R|kotlin/Unit| {
this@R|/anonymous|.R|/anonymous.invokeFunction|(R|<local>/v|)
R|<local>/v|.<Unresolved name: visitJumpInsn>#(when () {
R|<local>/jumpIfFalse| -> {
<Unresolved name: Opcodes>#.<Unresolved name: IFEQ>#
}
else -> {
<Unresolved name: Opcodes>#.<Unresolved name: IFNE>#
}
}
, R|<local>/jumpLabel|)
}
private final fun invokeFunction(v: R|ERROR CLASS: Symbol not found, for `InstructionAdapter`|): R|kotlin/Unit| {
lval result: <ERROR TYPE REF: Unresolved name: invokeFunction> = this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.codegen|.<Unresolved name: invokeFunction>#(this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|.<Unresolved name: call>#, this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.resolvedCall|, <Unresolved name: none>#())
R|<local>/result|.<Unresolved name: put>#(R|<local>/result|.<Unresolved name: type>#, R|<local>/result|.<Unresolved name: kotlinType>#, R|<local>/v|)
}
}
}
}
@@ -0,0 +1,63 @@
class Foo {
val x = 1
fun abc() = x
fun cba() = abc()
}
class Bar {
val x = ""
// NB: unused
fun Foo.abc() = x
fun bar(): Bar = this
// NB: unused
operator fun String.plus(bar: Bar): String {
return ""
}
// NB! abc() here is resolved to member Foo.abc(), and not to extension member of Bar
fun Foo.check() = abc() <!INAPPLICABLE_CANDIDATE!>+<!> bar()
// NB! + here is resolved to member String.plus (not to extension member above)
fun Foo.check2() = "" + bar()
}
fun Foo.ext() = x
fun bar() {
}
fun buz() {
bar()
}
fun f() {
val a = 10
val b = a
val d = ""
val c = <!UNRESOLVED_REFERENCE!>c<!>
<!UNRESOLVED_REFERENCE!>abc<!>()
fun bcd() {}
fun abc() {
val a = d
val b = a
bcd()
fun dcb() {}
dcb()
}
<!UNRESOLVED_REFERENCE!>dcb<!>()
abc()
}
@@ -0,0 +1,77 @@
FILE: access.kt
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final fun abc(): R|kotlin/Int| {
^abc this@R|/Foo|.R|/Foo.x|
}
public final fun cba(): R|kotlin/Int| {
^cba this@R|/Foo|.R|/Foo.abc|()
}
}
public final class Bar : R|kotlin/Any| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/String| = String()
public get(): R|kotlin/String|
public final fun R|Foo|.abc(): R|kotlin/Int| {
^abc this@R|/Bar.abc|.R|/Foo.x|
}
public final fun bar(): R|Bar| {
^bar this@R|/Bar|
}
public final operator fun R|kotlin/String|.plus(bar: R|Bar|): R|kotlin/String| {
^plus String()
}
public final fun R|Foo|.check(): <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]> {
^check this@R|/Bar.check|.R|/Foo.abc|().<Inapplicable(INAPPLICABLE): [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(this@R|/Bar|.R|/Bar.bar|())
}
public final fun R|Foo|.check2(): R|kotlin/String| {
^check2 String().R|kotlin/String.plus|(this@R|/Bar|.R|/Bar.bar|())
}
}
public final fun R|Foo|.ext(): R|kotlin/Int| {
^ext this@R|/ext|.R|/Foo.x|
}
public final fun bar(): R|kotlin/Unit| {
}
public final fun buz(): R|kotlin/Unit| {
R|/bar|()
}
public final fun f(): R|kotlin/Unit| {
lval a: R|kotlin/Int| = Int(10)
lval b: R|kotlin/Int| = R|<local>/a|
lval d: R|kotlin/String| = String()
lval c: <ERROR TYPE REF: Unresolved name: c> = <Unresolved name: c>#
<Unresolved name: abc>#()
local final fun bcd(): R|kotlin/Unit| {
}
local final fun abc(): R|kotlin/Unit| {
lval a: R|kotlin/String| = R|<local>/d|
lval b: R|kotlin/String| = R|<local>/a|
R|<local>/bcd|()
local final fun dcb(): R|kotlin/Unit| {
}
R|<local>/dcb|()
}
<Unresolved name: dcb>#()
R|<local>/abc|()
}
@@ -0,0 +1,6 @@
// Should be something like TYPE_MISMATCH here
@file:Some(return x)
const val x = 42
annotation class Some(val value: Int)
@@ -0,0 +1,13 @@
FILE: annotationWithReturn.kt
@FILE:R|Some|(^ R|/x|)
public final const val x: R|kotlin/Int| = Int(42)
public get(): R|kotlin/Int|
public final annotation class Some : R|kotlin/Annotation| {
public constructor(value: R|kotlin/Int|): R|Some| {
super<R|kotlin/Any|>()
}
public final val value: R|kotlin/Int| = R|<local>/value|
public get(): R|kotlin/Int|
}
@@ -0,0 +1,19 @@
annotation class MyAnn
fun bar(x: Int) {}
fun foo() {
@MyAnn
val x: Int
@MyAnn
x = @MyAnn 42
@MyAnn
bar(@MyAnn x)
val y = @MyAnn if (false) x else x
val z = @MyAnn try {
x
} catch (t: Throwable) {
0
}
}
@@ -0,0 +1,30 @@
FILE: annotations.kt
public final annotation class MyAnn : R|kotlin/Annotation| {
public constructor(): R|MyAnn| {
super<R|kotlin/Any|>()
}
}
public final fun bar(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun foo(): R|kotlin/Unit| {
@R|MyAnn|() lval x: R|kotlin/Int|
@R|MyAnn|() R|<local>/x| = @R|MyAnn|() Int(42)
@R|MyAnn|() R|/bar|(@R|MyAnn|() R|<local>/x|)
lval y: R|kotlin/Int| = @R|MyAnn|() when () {
Boolean(false) -> {
R|<local>/x|
}
else -> {
R|<local>/x|
}
}
lval z: R|kotlin/Int| = @R|MyAnn|() try {
R|<local>/x|
}
catch (t: R|kotlin/Throwable|) {
Int(0)
}
}
@@ -0,0 +1,25 @@
// FILE: JavaClass.java
public class JavaClass {
public static void bar() {}
}
// FILE: Test.kt
open class AA : JavaClass() {
object C
}
class BB : AA() {
object D
}
fun test() {
val bbd = BB.D
val aac = AA.C
JavaClass.bar()
val errC = BB.<!UNRESOLVED_REFERENCE!>C<!>
val errBarViaBB = BB.<!UNRESOLVED_REFERENCE!>bar<!>()
val errBarViaAA = AA.<!UNRESOLVED_REFERENCE!>bar<!>()
}
@@ -0,0 +1,35 @@
FILE: Test.kt
public open class AA : R|JavaClass| {
public constructor(): R|AA| {
super<R|JavaClass|>()
}
public final object C : R|kotlin/Any| {
private constructor(): R|AA.C| {
super<R|kotlin/Any|>()
}
}
}
public final class BB : R|AA| {
public constructor(): R|BB| {
super<R|AA|>()
}
public final object D : R|kotlin/Any| {
private constructor(): R|BB.D| {
super<R|kotlin/Any|>()
}
}
}
public final fun test(): R|kotlin/Unit| {
lval bbd: R|BB.D| = Q|BB.D|
lval aac: R|AA.C| = Q|AA.C|
Q|JavaClass|.R|/JavaClass.bar|()
lval errC: <ERROR TYPE REF: Unresolved name: C> = Q|BB|.<Unresolved name: C>#
lval errBarViaBB: <ERROR TYPE REF: Unresolved name: bar> = Q|BB|.<Unresolved name: bar>#()
lval errBarViaAA: <ERROR TYPE REF: Unresolved name: bar> = Q|AA|.<Unresolved name: bar>#()
}
@@ -0,0 +1,16 @@
class A
open class B
class C : B
fun bar(a: A) = a
fun bar(b: B) = b
fun foo() {
val a = A()
val b = B()
val c = C()
val ra = bar(a)
val rb = bar(b)
val rc = bar(c)
}
@@ -0,0 +1,33 @@
FILE: checkArguments.kt
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public open class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
}
public final fun bar(a: R|A|): R|A| {
^bar R|<local>/a|
}
public final fun bar(b: R|B|): R|B| {
^bar R|<local>/b|
}
public final fun foo(): R|kotlin/Unit| {
lval a: R|A| = R|/A.A|()
lval b: R|B| = R|/B.B|()
lval c: R|C| = R|/C.C|()
lval ra: R|A| = R|/bar|(R|<local>/a|)
lval rb: R|B| = R|/bar|(R|<local>/b|)
lval rc: R|B| = R|/bar|(R|<local>/c|)
}
@@ -0,0 +1,10 @@
class Factory {
sealed class Function {
object Default
}
companion object {
val f = Function
val x = Function.Default
}
}
@@ -0,0 +1,34 @@
FILE: classifierAccessFromCompanion.kt
public final class Factory : R|kotlin/Any| {
public constructor(): R|Factory| {
super<R|kotlin/Any|>()
}
public sealed class Function : R|kotlin/Any| {
private constructor(): R|Factory.Function| {
super<R|kotlin/Any|>()
}
public final object Default : R|kotlin/Any| {
private constructor(): R|Factory.Function.Default| {
super<R|kotlin/Any|>()
}
}
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|Factory.Companion| {
super<R|kotlin/Any|>()
}
public final val f: R|kotlin/Unit| = Q|Factory.Function|
public get(): R|kotlin/Unit|
public final val x: R|Factory.Function.Default| = Q|Factory.Function.Default|
public get(): R|Factory.Function.Default|
}
}
@@ -0,0 +1,26 @@
open class A {
companion object {
fun foo() {}
val D = ""
}
fun bar() {
foo()
}
}
class B {
companion object : A() {
fun baz() {}
val C = ""
}
}
fun test() {
A.foo()
B.bar()
B.baz()
val x = A.D
val y = B.C
val z = B.<!UNRESOLVED_REFERENCE!>D<!>
}
@@ -0,0 +1,51 @@
FILE: companion.kt
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|A.Companion| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
}
public final val D: R|kotlin/String| = String()
public get(): R|kotlin/String|
}
public final fun bar(): R|kotlin/Unit| {
this@R|/A.Companion|.R|/A.Companion.foo|()
}
}
public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|A| {
private constructor(): R|B.Companion| {
super<R|A|>()
}
public final fun baz(): R|kotlin/Unit| {
}
public final val C: R|kotlin/String| = String()
public get(): R|kotlin/String|
}
}
public final fun test(): R|kotlin/Unit| {
Q|A|.R|/A.Companion.foo|()
Q|B|.R|/A.bar|()
Q|B|.R|/B.Companion.baz|()
lval x: R|kotlin/String| = Q|A|.R|/A.Companion.D|
lval y: R|kotlin/String| = Q|B|.R|/B.Companion.C|
lval z: <ERROR TYPE REF: Unresolved name: D> = Q|B|.<Unresolved name: D>#
}
@@ -0,0 +1,9 @@
class My {
companion object {
fun My.foo() {}
}
fun test() {
foo()
}
}
@@ -0,0 +1,21 @@
FILE: companionExtension.kt
public final class My : R|kotlin/Any| {
public constructor(): R|My| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|My.Companion| {
super<R|kotlin/Any|>()
}
public final fun R|My|.foo(): R|kotlin/Unit| {
}
}
public final fun test(): R|kotlin/Unit| {
(this@R|/My.Companion|, this@R|/My|).R|/My.Companion.foo|()
}
}
@@ -0,0 +1,7 @@
class C {
fun create() = C()
}
fun foo() = C()
fun bar() = foo().create()
@@ -0,0 +1,17 @@
FILE: constructor.kt
public final class C : R|kotlin/Any| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
public final fun create(): R|C| {
^create R|/C.C|()
}
}
public final fun foo(): R|C| {
^foo R|/C.C|()
}
public final fun bar(): R|C| {
^bar R|/foo|().R|/C.create|()
}
@@ -0,0 +1,10 @@
interface Base {
fun check()
}
class My {
lateinit var delegate: Base
fun check() = delegate.check() // Should not resolve
}
@@ -0,0 +1,19 @@
FILE: dispatchReceiver.kt
public abstract interface Base : R|kotlin/Any| {
public abstract fun check(): R|kotlin/Unit|
}
public final class My : R|kotlin/Any| {
public constructor(): R|My| {
super<R|kotlin/Any|>()
}
public final lateinit var delegate: R|Base|
public get(): R|Base|
public set(value: R|Base|): R|kotlin/Unit|
public final fun check(): R|kotlin/Unit| {
^check this@R|/My|.R|/My.delegate|.R|/Base.check|()
}
}
@@ -0,0 +1,22 @@
enum class TestEnum {
FIRST,
SECOND,
THIRD {
fun foo() {}
}
}
fun use(some: Any?) {}
fun useEnum(some: TestEnum) {}
fun useVararg(vararg some: TestEnum) {}
fun test() {
use(TestEnum.FIRST)
useEnum(TestEnum.SECOND)
useEnum(TestEnum.THIRD)
useVararg(TestEnum.FIRST, TestEnum.SECOND)
<!INAPPLICABLE_CANDIDATE!>useVararg<!>(1, 2, 3, 4, 5)
}
@@ -0,0 +1,38 @@
FILE: enumEntryUse.kt
public final enum class TestEnum : R|kotlin/Enum<TestEnum>| {
private constructor(): R|TestEnum| {
super<R|kotlin/Enum<TestEnum>|>()
}
public final static enum entry FIRST: R|TestEnum|
public final static enum entry SECOND: R|TestEnum|
public final static enum entry THIRD: R|TestEnum| = object : R|TestEnum| {
private constructor(): R|anonymous| {
super<R|TestEnum|>()
}
public final fun foo(): R|kotlin/Unit| {
}
}
public final static fun values(): R|kotlin/Array<TestEnum>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|TestEnum| {
}
}
public final fun use(some: R|kotlin/Any?|): R|kotlin/Unit| {
}
public final fun useEnum(some: R|TestEnum|): R|kotlin/Unit| {
}
public final fun useVararg(vararg some: R|kotlin/Array<out TestEnum>|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/use|(Q|TestEnum|.R|/TestEnum.FIRST|)
R|/useEnum|(Q|TestEnum|.R|/TestEnum.SECOND|)
R|/useEnum|(Q|TestEnum|.R|/TestEnum.THIRD|)
R|/useVararg|(vararg(Q|TestEnum|.R|/TestEnum.FIRST|, Q|TestEnum|.R|/TestEnum.SECOND|))
<Inapplicable(INAPPLICABLE): [/useVararg]>#(Int(1), Int(2), Int(3), Int(4), Int(5))
}
@@ -0,0 +1,18 @@
enum class MyEnum {
FIRST,
SECOND,
LAST;
fun bar() = 42
}
fun foo() {
val values = MyEnum.values()
for (value in values) {
value.bar()
}
val first = MyEnum.valueOf("FIRST")
val last = MyEnum.valueOf("LAST")
}
@@ -0,0 +1,31 @@
FILE: enumValues.kt
public final enum class MyEnum : R|kotlin/Enum<MyEnum>| {
private constructor(): R|MyEnum| {
super<R|kotlin/Enum<MyEnum>|>()
}
public final static enum entry FIRST: R|MyEnum|
public final static enum entry SECOND: R|MyEnum|
public final static enum entry LAST: R|MyEnum|
public final fun bar(): R|kotlin/Int| {
^bar Int(42)
}
public final static fun values(): R|kotlin/Array<MyEnum>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|MyEnum| {
}
}
public final fun foo(): R|kotlin/Unit| {
lval values: R|kotlin/Array<MyEnum>| = Q|MyEnum|.R|/MyEnum.values|()
lval <iterator>: R|kotlin/collections/Iterator<MyEnum>| = R|<local>/values|.R|FakeOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<MyEnum>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval value: R|MyEnum| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|MyEnum|>|()
R|<local>/value|.R|/MyEnum.bar|()
}
lval first: R|MyEnum| = Q|MyEnum|.R|/MyEnum.valueOf|(String(FIRST))
lval last: R|MyEnum| = Q|MyEnum|.R|/MyEnum.valueOf|(String(LAST))
}
@@ -0,0 +1,13 @@
class Your {
class Nested
}
class My {
fun foo() {
val x = <!UNRESOLVED_REFERENCE!>::Nested<!> // Should be error
}
}
fun Your.foo() {
val x = <!UNRESOLVED_REFERENCE!>::Nested<!> // Still should be error
}
@@ -0,0 +1,27 @@
FILE: errCallable.kt
public final class Your : R|kotlin/Any| {
public constructor(): R|Your| {
super<R|kotlin/Any|>()
}
public final class Nested : R|kotlin/Any| {
public constructor(): R|Your.Nested| {
super<R|kotlin/Any|>()
}
}
}
public final class My : R|kotlin/Any| {
public constructor(): R|My| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
lval x: <ERROR TYPE REF: No result type for initializer> = ::<Unresolved name: Nested>#
}
}
public final fun R|Your|.foo(): R|kotlin/Unit| {
lval x: <ERROR TYPE REF: No result type for initializer> = ::<Unresolved name: Nested>#
}
@@ -0,0 +1,14 @@
class C<T>(var x: T)
var <T> C<T>.y
get() = x
set(v) {
x = v
}
fun use(f: () -> String) {}
fun test1() {
use { C("abc").y }
use(C("abc")::y)
}
@@ -0,0 +1,27 @@
FILE: extensionPropertyInLambda.kt
public final class C<T> : R|kotlin/Any| {
public constructor<T>(x: R|T|): R|C<T>| {
super<R|kotlin/Any|>()
}
public final var x: R|T| = R|<local>/x|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
}
public final var <T> R|C<T>|.y: R|T|
public get(): R|T| {
^ this@R|/y|.R|FakeOverride</C.x: R|T|>|
}
public set(v: R|T|): R|kotlin/Unit| {
this@R|/y|.R|FakeOverride</C.x: R|T|>| = R|<local>/v|
}
public final fun use(f: R|() -> kotlin/String|): R|kotlin/Unit| {
}
public final fun test1(): R|kotlin/Unit| {
R|/use|(<L> = use@fun <anonymous>(): R|kotlin/String| {
^ R|/C.C|<R|kotlin/String|>(String(abc)).R|/y|<R|kotlin/String|>
}
)
R|/use|(R|/C.C|<R|kotlin/String|>(String(abc))::R|/y<kotlin/String>|)
}
@@ -0,0 +1,19 @@
// FILE: LookupElement.java
public abstract class LookupElement {
public abstract String getLookupString();
}
// FILE: Decorator.java
public abstract class Decorator<T extends LookupElement> extends LookupElement {
public T getDelegate() {
return null;
}
}
// FILE: test.kt
class MyDecorator : Decorator<LookupElement> {
override fun getLookupString(): String = delegate.lookupString
}
@@ -0,0 +1,11 @@
FILE: test.kt
public final class MyDecorator : R|Decorator<LookupElement>| {
public constructor(): R|MyDecorator| {
super<R|kotlin/Any|>()
}
public final override fun getLookupString(): R|kotlin/String| {
^getLookupString this@R|/MyDecorator|.R|/MyDecorator.delegate|.R|/LookupElement.lookupString|
}
}
@@ -0,0 +1,41 @@
// FILE: Descriptor.java
// FULL_JDK
public interface Descriptor
// FILE: ResolvedCall.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface ResolvedCall<D extends Descriptor> {
@NotNull
D getResultingDescriptor();
@Nullable
D getCandidateDescriptor();
}
// FILE: test.kt
val Descriptor.name = "123"
fun Descriptor.correct(): Boolean = true
fun Descriptor.foo() {}
interface Call<D : Descriptor> {
val resultingDescriptor: D
}
fun <D : Descriptor> test(call: Call<D>, resolvedCall: ResolvedCall<D>) {
call.resultingDescriptor.name
resolvedCall.resultingDescriptor.name
val resolvedDescriptor = resolvedCall.candidateDescriptor
if (resolvedDescriptor?.correct() != true) return
resolvedDescriptor.foo()
}
fun otherTest(call: Call<*>, resolvedCall: ResolvedCall<*>) {
call.resultingDescriptor.name
resolvedCall.resultingDescriptor.name
}
@@ -0,0 +1,29 @@
FILE: test.kt
public final val R|Descriptor|.name: R|kotlin/String| = String(123)
public get(): R|kotlin/String|
public final fun R|Descriptor|.correct(): R|kotlin/Boolean| {
^correct Boolean(true)
}
public final fun R|Descriptor|.foo(): R|kotlin/Unit| {
}
public abstract interface Call<D : R|Descriptor|> : R|kotlin/Any| {
public abstract val resultingDescriptor: R|D|
public get(): R|D|
}
public final fun <D : R|Descriptor|> test(call: R|Call<D>|, resolvedCall: R|ResolvedCall<D>|): R|kotlin/Unit| {
R|<local>/call|.R|FakeOverride</Call.resultingDescriptor: R|D|>|.R|/name|
R|<local>/resolvedCall|.R|/ResolvedCall.resultingDescriptor|.R|/name|
lval resolvedDescriptor: R|D?| = R|<local>/resolvedCall|.R|/ResolvedCall.candidateDescriptor|
when () {
!=(R|<local>/resolvedDescriptor|?.R|/correct|(), Boolean(true)) -> {
^test Unit
}
}
R|<local>/resolvedDescriptor|.R|/foo|()
}
public final fun otherTest(call: R|Call<*>|, resolvedCall: R|ResolvedCall<*>|): R|kotlin/Unit| {
R|<local>/call|.R|FakeOverride</Call.resultingDescriptor: R|Descriptor|>|.R|/name|
R|<local>/resolvedCall|.R|/ResolvedCall.resultingDescriptor|.R|/name|
}
@@ -0,0 +1,57 @@
// FILE: Element.java
// FULL_JDK
public interface Element {}
// FILE: DerivedElement.java
public interface DerivedElement extends Element {}
// FILE: EmptyDiagnostic.java
public class EmptyDiagnostic {}
// FILE: Diagnostic.java
import org.jetbrains.annotations.NotNull;
public class Diagnostic<E extends Element> extends EmptyDiagnostic {
@NotNull
public E getElement();
}
// FILE: DiagnosticFactory.java
import org.jetbrains.annotations.NotNull;
public class DiagnosticFactory<D extends EmptyDiagnostic> {
@NotNull
public D cast(@NotNull EmptyDiagnostic diagnostic) {
return (D) diagnostic;
}
}
// FILE: DiagnosticFactory0.java
public class DiagnosticFactory0<E extends Element> extends DiagnosticFactory<Diagnostic<E>> {}
// FILE: test.kt
class Fix(e: DerivedElement)
fun create(d: Diagnostic<DerivedElement>) {
val element = d.element
Fix(element)
}
fun <DE : DerivedElement> createGeneric(d: Diagnostic<DE>) {
val element = d.element
Fix(element)
}
private val DERIVED_FACTORY = DiagnosticFactory0<DerivedElement>()
fun createViaFactory(d: EmptyDiagnostic) {
val casted = DERIVED_FACTORY.cast(d)
val element = casted.element
Fix(element)
}
@@ -0,0 +1,22 @@
FILE: test.kt
public final class Fix : R|kotlin/Any| {
public constructor(e: R|DerivedElement|): R|Fix| {
super<R|kotlin/Any|>()
}
}
public final fun create(d: R|Diagnostic<DerivedElement>|): R|kotlin/Unit| {
lval element: R|DerivedElement| = R|<local>/d|.R|/Diagnostic.element|
R|/Fix.Fix|(R|<local>/element|)
}
public final fun <DE : R|DerivedElement|> createGeneric(d: R|Diagnostic<DE>|): R|kotlin/Unit| {
lval element: R|DE| = R|<local>/d|.R|/Diagnostic.element|
R|/Fix.Fix|(R|<local>/element|)
}
private final val DERIVED_FACTORY: R|DiagnosticFactory0<DerivedElement>| = R|/DiagnosticFactory0.DiagnosticFactory0|<R|DerivedElement|>()
private get(): R|DiagnosticFactory0<DerivedElement>|
public final fun createViaFactory(d: R|EmptyDiagnostic|): R|kotlin/Unit| {
lval casted: R|Diagnostic<ft<DerivedElement, DerivedElement?>!>| = R|/DERIVED_FACTORY|.R|FakeOverride</DiagnosticFactory0.cast: R|Diagnostic<ft<DerivedElement, DerivedElement?>!>|>|(R|<local>/d|)
lval element: R|DerivedElement| = R|<local>/casted|.R|/Diagnostic.element|
R|/Fix.Fix|(R|<local>/element|)
}
@@ -0,0 +1,7 @@
abstract class Base<T>(val x: T) {
abstract fun foo(): T
}
class Derived<T>(x: T) : Base<T>(x) {
override fun foo(): T = x
}
@@ -0,0 +1,22 @@
FILE: genericPropertyAccess.kt
public abstract class Base<T> : R|kotlin/Any| {
public constructor<T>(x: R|T|): R|Base<T>| {
super<R|kotlin/Any|>()
}
public final val x: R|T| = R|<local>/x|
public get(): R|T|
public abstract fun foo(): R|T|
}
public final class Derived<T> : R|Base<T>| {
public constructor<T>(x: R|T|): R|Derived<T>| {
super<R|Base<T>|>(R|<local>/x|)
}
public final override fun foo(): R|T| {
^foo this@R|/Derived|.R|FakeOverride</Derived.x: R|T|>|
}
}
@@ -0,0 +1,9 @@
class Generic<T : CharSequence?>(val value: T) {
fun foo(): T = value
}
fun test(arg: Generic<String>) {
val value = arg.value
val foo = arg.foo()
val length = foo.length + value.length
}
@@ -0,0 +1,19 @@
FILE: genericUsedInFunction.kt
public final class Generic<T : R|kotlin/CharSequence?|> : R|kotlin/Any| {
public constructor<T : R|kotlin/CharSequence?|>(value: R|T|): R|Generic<T>| {
super<R|kotlin/Any|>()
}
public final val value: R|T| = R|<local>/value|
public get(): R|T|
public final fun foo(): R|T| {
^foo this@R|/Generic|.R|/Generic.value|
}
}
public final fun test(arg: R|Generic<kotlin/String>|): R|kotlin/Unit| {
lval value: R|kotlin/String| = R|<local>/arg|.R|FakeOverride</Generic.value: R|kotlin/String|>|
lval foo: R|kotlin/String| = R|<local>/arg|.R|FakeOverride</Generic.foo: R|kotlin/String|>|()
lval length: R|kotlin/Int| = R|<local>/foo|.R|kotlin/String.length|.R|kotlin/Int.plus|(R|<local>/value|.R|kotlin/String.length|)
}
@@ -0,0 +1,31 @@
import My.bar
import My.baz
import My.gau
import My.wat
import My.watwat
fun <T> T.foo() {}
interface Your<R> {
fun wat() {}
fun <T> T.watwat() {}
}
object My : Your<Double> {
fun <T> T.bar() {}
fun baz()
fun Boolean.gau() {}
}
fun test() {
42.foo()
"".foo()
42.bar()
"".bar()
baz()
true.gau()
wat()
false.watwat()
}
@@ -0,0 +1,35 @@
FILE: importedReceiver.kt
public final fun <T> R|T|.foo(): R|kotlin/Unit| {
}
public abstract interface Your<R> : R|kotlin/Any| {
public open fun wat(): R|kotlin/Unit| {
}
public open fun <T> R|T|.watwat(): R|kotlin/Unit| {
}
}
public final object My : R|Your<kotlin/Double>| {
private constructor(): R|My| {
super<R|kotlin/Any|>()
}
public final fun <T> R|T|.bar(): R|kotlin/Unit| {
}
public final fun baz(): R|kotlin/Unit|
public final fun R|kotlin/Boolean|.gau(): R|kotlin/Unit| {
}
}
public final fun test(): R|kotlin/Unit| {
Int(42).R|/foo|<R|kotlin/Int|>()
String().R|/foo|<R|kotlin/String|>()
Int(42).R|/My.bar|<R|kotlin/Int|>()
String().R|/My.bar|<R|kotlin/String|>()
R|/My.baz|()
Boolean(true).R|/My.gau|()
R|/Your.wat|()
Boolean(false).R|FakeOverride</My.watwat: R|kotlin/Unit|>|<R|kotlin/Boolean|>()
}
@@ -0,0 +1,8 @@
fun <T> id(t: T) = t
fun main() {
val a = id("string")
val b = id(null)
val c = id(id(a))
}
@@ -0,0 +1,9 @@
FILE: id.kt
public final fun <T> id(t: R|T|): R|T| {
^id R|<local>/t|
}
public final fun main(): R|kotlin/Unit| {
lval a: R|kotlin/String| = R|/id|<R|kotlin/String|>(String(string))
lval b: R|kotlin/Nothing?| = R|/id|<R|kotlin/Nothing?|>(Null(null))
lval c: R|kotlin/String| = R|/id|<R|kotlin/String|>(R|/id|<R|kotlin/String|>(R|<local>/a|))
}
@@ -0,0 +1,11 @@
interface Foo
class FooImpl : Foo
class Bar
fun <T : Foo> foo(t: T) = t
fun main(fooImpl: FooImpl, bar: Bar) {
val a = foo(fooImpl)
val b = <!INAPPLICABLE_CANDIDATE!>foo<!>(bar)
}
@@ -0,0 +1,22 @@
FILE: typeParameters.kt
public abstract interface Foo : R|kotlin/Any| {
}
public final class FooImpl : R|Foo| {
public constructor(): R|FooImpl| {
super<R|kotlin/Any|>()
}
}
public final class Bar : R|kotlin/Any| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
}
public final fun <T : R|Foo|> foo(t: R|T|): R|T| {
^foo R|<local>/t|
}
public final fun main(fooImpl: R|FooImpl|, bar: R|Bar|): R|kotlin/Unit| {
lval a: R|FooImpl| = R|/foo|<R|FooImpl|>(R|<local>/fooImpl|)
lval b: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#(R|<local>/bar|)
}
@@ -0,0 +1,11 @@
interface Foo
class FooImpl : Foo
class FooBarImpl : Foo
fun <T : Foo> foo(t: T) = t
fun main(fooImpl: FooImpl, fooBarImpl: FooBarImpl) {
val a = <!INAPPLICABLE_CANDIDATE!>foo<!><FooImpl>(fooBarImpl)
val b = foo<Foo>(fooImpl)
}
@@ -0,0 +1,22 @@
FILE: typeParameters2.kt
public abstract interface Foo : R|kotlin/Any| {
}
public final class FooImpl : R|Foo| {
public constructor(): R|FooImpl| {
super<R|kotlin/Any|>()
}
}
public final class FooBarImpl : R|Foo| {
public constructor(): R|FooBarImpl| {
super<R|kotlin/Any|>()
}
}
public final fun <T : R|Foo|> foo(t: R|T|): R|T| {
^foo R|<local>/t|
}
public final fun main(fooImpl: R|FooImpl|, fooBarImpl: R|FooBarImpl|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#<R|FooImpl|>(R|<local>/fooBarImpl|)
lval b: R|Foo| = R|/foo|<R|Foo|>(R|<local>/fooImpl|)
}
@@ -0,0 +1,6 @@
class Outer {
inner class Inner
}
val x = Outer.Inner
val klass = Outer.Inner::class
@@ -0,0 +1,18 @@
FILE: innerQualifier.kt
public final class Outer : R|kotlin/Any| {
public constructor(): R|Outer| {
super<R|kotlin/Any|>()
}
public final inner class Inner : R|kotlin/Any| {
public constructor(): R|Outer.Inner| {
super<R|kotlin/Any|>()
}
}
}
public final val x: R|kotlin/Unit| = Q|Outer.Inner|
public get(): R|kotlin/Unit|
public final val klass: R|kotlin/reflect/KClass<Outer.Inner>| = <getClass>(Q|Outer.Inner|)
public get(): R|kotlin/reflect/KClass<Outer.Inner>|
@@ -0,0 +1,13 @@
open class Base {
companion object {
val some = 0
}
}
class Outer {
val codegen = ""
inner class Inner : Base() {
val c = codegen
}
}
@@ -0,0 +1,36 @@
FILE: innerWithSuperCompanion.kt
public open class Base : R|kotlin/Any| {
public constructor(): R|Base| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|Base.Companion| {
super<R|kotlin/Any|>()
}
public final val some: R|kotlin/Int| = Int(0)
public get(): R|kotlin/Int|
}
}
public final class Outer : R|kotlin/Any| {
public constructor(): R|Outer| {
super<R|kotlin/Any|>()
}
public final val codegen: R|kotlin/String| = String()
public get(): R|kotlin/String|
public final inner class Inner : R|Base| {
public constructor(): R|Outer.Inner| {
super<R|Base|>()
}
public final val c: R|kotlin/String| = this@R|/Outer|.R|/Outer.codegen|
public get(): R|kotlin/String|
}
}
@@ -0,0 +1,3 @@
fun String.k(): () -> String = { -> this }
fun test() = "hello".k()()
@@ -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|>|()
}
@@ -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()
}
}
@@ -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|()
}
}
@@ -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
}
@@ -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|()
}
}
@@ -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
}
@@ -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|()
}
}
@@ -0,0 +1,10 @@
object X
class Y {
fun f(op: X.() -> Unit) {
X.op()
val x = X
x.op()
}
}
@@ -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|)
}
}
@@ -0,0 +1,4 @@
fun bar(doIt: Int.() -> Int) {
val i: Int? = 1
i?.<!INAPPLICABLE_CANDIDATE!>doIt<!>()
}
@@ -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]>#()
}
@@ -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
}
@@ -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|()
}
}
@@ -0,0 +1,10 @@
class A {
fun bar() = foo() // should resolve to invoke
fun invoke() = this
}
fun create() = A()
val foo = create()
@@ -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|
@@ -0,0 +1,4 @@
fun test(e: Int.() -> String) {
val s = 3.e()
val ss = 3.(e)()
}
@@ -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))
}
@@ -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()
}
@@ -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|()
}
@@ -0,0 +1,3 @@
class Bar(name: () -> String) {
val name = name()
}
@@ -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|
}
@@ -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()
}
@@ -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|()
}
@@ -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<!>()
}
}
@@ -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>#()
}
}
@@ -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)
}
}
}
}
@@ -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|)
}
)
}
)
}
)
}
@@ -0,0 +1,13 @@
// FILE: JavaClass.java
public class JavaClass {
public static String staticField;
public String nonStaticField;
}
// FILE: test.kt
fun test() {
val staticReference = JavaClass::staticField
val nonStaticReference = JavaClass::nonStaticField
}
@@ -0,0 +1,5 @@
FILE: test.kt
public final fun test(): R|kotlin/Unit| {
lval staticReference: R|kotlin/reflect/KMutableProperty0<ft<kotlin/String, kotlin/String?>!>| = Q|JavaClass|::R|/JavaClass.staticField|
lval nonStaticReference: R|kotlin/reflect/KMutableProperty1<JavaClass, ft<kotlin/String, kotlin/String?>!>| = Q|JavaClass|::R|/JavaClass.nonStaticField|
}
@@ -0,0 +1,17 @@
fun foo(block: () -> Unit) {}
fun bar(block: () -> String) {}
fun itIs(block: (String) -> String) {}
fun multipleArgs(block: (String, String) -> String) {}
fun main() {
foo { "This is test" }
bar { "This is also test" }
itIs { "this is $it test" }
multipleArgs { a, b -> "This is test of $a, $b" }
val s = { "OK" }()
val f = { "OK" }
val ss = f.invoke()
}
@@ -0,0 +1,36 @@
FILE: lambda.kt
public final fun foo(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun bar(block: R|() -> kotlin/String|): R|kotlin/Unit| {
}
public final fun itIs(block: R|(kotlin/String) -> kotlin/String|): R|kotlin/Unit| {
}
public final fun multipleArgs(block: R|(kotlin/String, kotlin/String) -> kotlin/String|): R|kotlin/Unit| {
}
public final fun main(): R|kotlin/Unit| {
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
^ String(This is test)
}
)
R|/bar|(<L> = bar@fun <anonymous>(): R|kotlin/String| {
^ String(This is also test)
}
)
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| {
^ <strcat>(String(this is ), R|<local>/it|.R|kotlin/Any.toString|(), String( test))
}
)
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| {
^ <strcat>(String(This is test of ), R|<local>/a|.R|kotlin/Any.toString|(), String(, ), R|<local>/b|.R|kotlin/Any.toString|())
}
)
lval s: R|kotlin/String| = fun <anonymous>(): R|kotlin/String| {
^ String(OK)
}
.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
lval f: R|() -> kotlin/String| = fun <anonymous>(): R|kotlin/String| {
^ String(OK)
}
lval ss: R|kotlin/String| = R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
}
@@ -0,0 +1,41 @@
interface A {
fun foo()
}
fun <T> myWith(receiver: T, block: T.() -> Unit) {
receiver.block()
}
fun <T> T.myApply(block: T.() -> Unit) {
this.block()
}
fun withA(block: A.() -> Unit) {}
fun test_1() {
withA {
foo()
}
}
fun test_2(a: A) {
myWith(a) {
foo()
}
}
fun test_3(a: A) {
a.myApply {
foo()
}
}
fun complexLambda(block: Int.(String) -> Unit) {}
fun test_4() {
complexLambda {
inc()
this.inc()
it.length
}
}
@@ -0,0 +1,41 @@
FILE: lambdaWithReceiver.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public final fun <T> myWith(receiver: R|T|, block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/block|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/receiver|)
}
public final fun <T> R|T|.myApply(block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/block|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(this@R|/myApply|)
}
public final fun withA(block: R|A.() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun test_1(): R|kotlin/Unit| {
R|/withA|(<L> = withA@fun R|A|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/A.foo|()
}
)
}
public final fun test_2(a: R|A|): R|kotlin/Unit| {
R|/myWith|<R|A|>(R|<local>/a|, <L> = myWith@fun R|A|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/A.foo|()
}
)
}
public final fun test_3(a: R|A|): R|kotlin/Unit| {
R|<local>/a|.R|/myApply|<R|A|>(<L> = myApply@fun R|A|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|/A.foo|()
}
)
}
public final fun complexLambda(block: R|kotlin/Int.(kotlin/String) -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun test_4(): R|kotlin/Unit| {
R|/complexLambda|(<L> = complexLambda@fun R|kotlin/Int|.<anonymous>(it: R|kotlin/String|): R|kotlin/Unit| {
this@R|special/anonymous|.R|kotlin/Int.inc|()
this@R|special/anonymous|.R|kotlin/Int.inc|()
^ R|<local>/it|.R|kotlin/String.length|
}
)
}
@@ -0,0 +1,11 @@
class Outer {
fun foo() {
class Local {
fun bar() {
val x = y
}
}
}
val y = ""
}
@@ -0,0 +1,24 @@
FILE: localClassAccessesContainingClass.kt
public final class Outer : R|kotlin/Any| {
public constructor(): R|Outer| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
local final class Local : R|kotlin/Any| {
public constructor(): R|Outer.Local| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
lval x: R|kotlin/String| = this@R|/Outer|.R|/Outer.y|
}
}
}
public final val y: R|kotlin/String| = String()
public get(): R|kotlin/String|
}
@@ -0,0 +1,5 @@
fun test() {
class Local
val l = Local()
}
@@ -0,0 +1,11 @@
FILE: localConstructor.kt
public final fun test(): R|kotlin/Unit| {
local final class Local : R|kotlin/Any| {
public constructor(): R|Local| {
super<R|kotlin/Any|>()
}
}
lval l: R|Local| = R|/Local.Local|()
}
@@ -0,0 +1,6 @@
class Foo {
fun test() {
fun Foo.bar() {}
bar()
}
}
@@ -0,0 +1,14 @@
FILE: localExtension.kt
public final class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public final fun test(): R|kotlin/Unit| {
local final fun R|Foo|.bar(): R|kotlin/Unit| {
}
this@R|/Foo|.R|<local>/bar|()
}
}
@@ -0,0 +1,7 @@
fun foo() {
val x = object {
fun sss() = abc()
fun abc() = 1
}
val g = x.sss()
}
@@ -0,0 +1,25 @@
FILE: localImplicitBodies.kt
public final fun foo(): R|kotlin/Unit| {
lval x: R|anonymous| = object : R|kotlin/Any| {
private constructor(): R|anonymous| {
super<R|kotlin/Any|>()
}
public final fun sss(): <ERROR TYPE REF: Cannot calculate return type during full-body resolution (local class/object?): public final fun abc(): <implicit> {
^abc IntegerLiteral(1)
}
> {
^sss R?C|/anonymous.abc|()
}
public final fun abc(): R|kotlin/Int| {
^abc Int(1)
}
}
lval g: <ERROR TYPE REF: Cannot calculate return type during full-body resolution (local class/object?): public final fun abc(): <implicit> {
^abc IntegerLiteral(1)
}
> = R|<local>/x|.R?C|/anonymous.sss|()
}
@@ -0,0 +1,11 @@
interface Foo
fun bar() {
object : Foo {
fun foo(): Foo {
return Derived(42)
}
inner class Derived(val x: Int) : Foo
}
}
@@ -0,0 +1,26 @@
FILE: localInnerClass.kt
public abstract interface Foo : R|kotlin/Any| {
}
public final fun bar(): R|kotlin/Unit| {
object : R|Foo| {
private constructor(): R|anonymous| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|Foo| {
^foo this@R|/anonymous|.R|/<anonymous>.Derived.Derived|(Int(42))
}
local final inner class Derived : R|Foo| {
public constructor(x: R|kotlin/Int|): R|<anonymous>.Derived| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|
public get(): R|kotlin/Int|
}
}
}
@@ -0,0 +1,21 @@
object A {
val x : Int = 0
}
open class Foo {
fun foo() : Int = 1
}
fun test() {
A.x
val b = object : Foo() {
}
b.foo()
object B {
fun foo() {}
}
B.foo()
}
val bb = <!UNRESOLVED_REFERENCE!>B<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -0,0 +1,44 @@
FILE: localObjects.kt
public final object A : R|kotlin/Any| {
private constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = Int(0)
public get(): R|kotlin/Int|
}
public open class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Int| {
^foo Int(1)
}
}
public final fun test(): R|kotlin/Unit| {
Q|A|.R|/A.x|
lval b: R|anonymous| = object : R|Foo| {
private constructor(): R|anonymous| {
super<R|Foo|>()
}
}
R|<local>/b|.R|/Foo.foo|()
local final object B : R|kotlin/Any| {
private constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
}
}
Q|B|.R|/B.foo|()
}
public final val bb: <ERROR TYPE REF: Unresolved name: foo> = <Unresolved name: B>#.<Unresolved name: foo>#()
public get(): <ERROR TYPE REF: Unresolved name: foo>

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