[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// FILE: K1.kt
|
||||
class K2: J1() {
|
||||
class Q : Nested()
|
||||
fun bar() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>superClass<!>()
|
||||
<!UNRESOLVED_REFERENCE!>superI<!>()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J1.java
|
||||
public class J1 extends K2() {
|
||||
public class Nested {}
|
||||
|
||||
void baz() {}
|
||||
}
|
||||
|
||||
// FILE: K2.kt
|
||||
open class KFirst : SuperClass(), SuperI {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K3.kt
|
||||
abstract class SuperClass {
|
||||
fun superClass() {}
|
||||
}
|
||||
|
||||
interface SuperI {
|
||||
fun superI() {}
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
FILE: K1.kt
|
||||
public final class K2 : R|J1| {
|
||||
public constructor(): R|K2| {
|
||||
super<R|J1|>()
|
||||
}
|
||||
|
||||
public final class Q : R|ERROR CLASS: Symbol not found, for `Nested`| {
|
||||
public constructor(): R|K2.Q| {
|
||||
super<R|ERROR CLASS: Symbol not found, for `Nested`|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
<Unresolved name: foo>#()
|
||||
<Unresolved name: baz>#()
|
||||
<Unresolved name: superClass>#()
|
||||
<Unresolved name: superI>#()
|
||||
}
|
||||
|
||||
}
|
||||
FILE: K2.kt
|
||||
public open class KFirst : R|SuperClass|, R|SuperI| {
|
||||
public constructor(): R|KFirst| {
|
||||
super<R|SuperClass|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
FILE: K3.kt
|
||||
public abstract class SuperClass : R|kotlin/Any| {
|
||||
public constructor(): R|SuperClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun superClass(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface SuperI : R|kotlin/Any| {
|
||||
public open fun superI(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
class A {
|
||||
fun bar() {
|
||||
val foo: String.() -> Unit = {} // (1)
|
||||
fun String.foo(): Unit {} // (2)
|
||||
"1".foo() // resolves to (2)
|
||||
with("2") {
|
||||
foo() // BUG: resolves to (1) in old FE, but to (2) in FIR
|
||||
}
|
||||
}
|
||||
}
|
||||
class B {
|
||||
val foo: String.() -> Unit = {} // (1)
|
||||
fun String.foo(): Unit {} // (2)
|
||||
fun bar() {
|
||||
"1".foo() // resolves to (2)
|
||||
with("2") {
|
||||
foo() // resolves to (2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class E {
|
||||
object f {
|
||||
operator fun invoke() = Unit // (1)
|
||||
}
|
||||
companion object {
|
||||
val f: () -> Unit = {} // (2)
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
E.f() // Resolves to (2) in old FE (to (1) in FIR with object implicit invoke support)
|
||||
E.f.invoke() // Resolves to (1)
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
FILE: invokePriority.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
lval foo: R|kotlin/String.() -> kotlin/Unit| = fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| {
|
||||
Unit
|
||||
}
|
||||
|
||||
local final fun R|kotlin/String|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
String(1).R|<local>/foo|()
|
||||
R|kotlin/with|<R|kotlin/String|, R|kotlin/Unit|>(String(2), <L> = with@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||
this@R|special/anonymous|.R|<local>/foo|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val foo: R|kotlin/String.() -> kotlin/Unit| = fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| {
|
||||
Unit
|
||||
}
|
||||
|
||||
public get(): R|kotlin/String.() -> kotlin/Unit|
|
||||
|
||||
public final fun R|kotlin/String|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
(this@R|/B|, String(1)).R|/B.foo|()
|
||||
R|kotlin/with|<R|kotlin/String|, R|kotlin/Unit|>(String(2), <L> = with@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||
(this@R|/B|, this@R|special/anonymous|).R|/B.foo|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
public final class E : R|kotlin/Any| {
|
||||
public constructor(): R|E| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final object f : R|kotlin/Any| {
|
||||
private constructor(): R|E.f| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(): R|kotlin/Unit| {
|
||||
^invoke Q|kotlin/Unit|
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|E.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val f: R|() -> kotlin/Unit| = fun <anonymous>(): R|kotlin/Unit| {
|
||||
Unit
|
||||
}
|
||||
|
||||
public get(): R|() -> kotlin/Unit|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|E|.R|/E.Companion.f|.R|/E.f.invoke|()
|
||||
Q|E.f|.R|/E.f.invoke|()
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class AHolder(val a: Int)
|
||||
|
||||
class F {
|
||||
object foo { // (1)
|
||||
val a: Int = 42
|
||||
}
|
||||
companion object { // (2)
|
||||
val foo: AHolder = AHolder(52)
|
||||
}
|
||||
}
|
||||
class FF {
|
||||
object foo {} // (1)
|
||||
companion object { // (2)
|
||||
val foo: AHolder = AHolder(52)
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
F.foo.a // (1) everywhere
|
||||
F.foo // (2) in old FE, (1) in FIR
|
||||
// Why companion?
|
||||
with(F.foo) {
|
||||
a // (2) in old FE, (1) in FIR
|
||||
}
|
||||
FF.foo.<!UNRESOLVED_REFERENCE!>a<!> // (1) everywhere
|
||||
// Why not companion
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
FILE: qualifierPriority.kt
|
||||
public final class AHolder : R|kotlin/Any| {
|
||||
public constructor(a: R|kotlin/Int|): R|AHolder| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val a: R|kotlin/Int| = R|<local>/a|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
public final class F : R|kotlin/Any| {
|
||||
public constructor(): R|F| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final object foo : R|kotlin/Any| {
|
||||
private constructor(): R|F.foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val a: R|kotlin/Int| = Int(42)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|F.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val foo: R|AHolder| = R|/AHolder.AHolder|(Int(52))
|
||||
public get(): R|AHolder|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class FF : R|kotlin/Any| {
|
||||
public constructor(): R|FF| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final object foo : R|kotlin/Any| {
|
||||
private constructor(): R|FF.foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|FF.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val foo: R|AHolder| = R|/AHolder.AHolder|(Int(52))
|
||||
public get(): R|AHolder|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
Q|F.foo|.R|/F.foo.a|
|
||||
Q|F.foo|
|
||||
R|kotlin/with|<R|F.foo|, R|kotlin/Int|>(Q|F.foo|, <L> = with@fun R|F.foo|.<anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||
^ this@R|special/anonymous|.R|/F.foo.a|
|
||||
}
|
||||
)
|
||||
Q|FF.foo|.<Unresolved name: a>#
|
||||
}
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* UNEXPECTED BEHAVIOUR
|
||||
* ISSUES: KT-37431
|
||||
*/
|
||||
|
||||
class Case1() {
|
||||
|
||||
fun foo() {
|
||||
val x = sequence<String> {
|
||||
|
||||
val y = this
|
||||
//this is Case1 instead of SequenceScope<String>
|
||||
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
|
||||
|
||||
this.<!UNRESOLVED_REFERENCE!>yield<!>("") //UNRESOLVED_REFERENCE
|
||||
|
||||
this as SequenceScope<String>
|
||||
|
||||
yield("") // resolved to SequenceScope.yield
|
||||
|
||||
this.yield("") // resolved to SequenceScope.yield
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun case2() {
|
||||
val x = sequence<String> {
|
||||
|
||||
val y = this
|
||||
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
|
||||
|
||||
this.<!UNRESOLVED_REFERENCE!>yield<!>("") //UNRESOLVED_REFERENCE
|
||||
|
||||
this as SequenceScope<String>
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
|
||||
|
||||
this.<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
|
||||
}
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
FILE: receiverResolutionInLambda.kt
|
||||
public final class Case1 : R|kotlin/Any| {
|
||||
public constructor(): R|Case1| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval x: R|kotlin/sequences/Sequence<kotlin/String>| = R|kotlin/sequences/sequence|<R|kotlin/String|>(<L> = sequence@fun <anonymous>(): R|kotlin/Unit| {
|
||||
lval y: R|Case1| = this@R|/Case1|
|
||||
<Unresolved name: yield>#(String())
|
||||
this@R|/Case1|.<Unresolved name: yield>#(String())
|
||||
(this@R|/Case1| as R|kotlin/sequences/SequenceScope<kotlin/String>|)
|
||||
this@R|/Case1|.R|FakeOverride<kotlin/sequences/SequenceScope.yield: R|kotlin/Unit|>|(String())
|
||||
this@R|/Case1|.R|FakeOverride<kotlin/sequences/SequenceScope.yield: R|kotlin/Unit|>|(String())
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case2(): R|kotlin/Unit| {
|
||||
lval x: R|kotlin/sequences/Sequence<kotlin/String>| = R|kotlin/sequences/sequence|<R|kotlin/String|>(<L> = sequence@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: yield> {
|
||||
lval y: R|ERROR CLASS: Unresolved this@null| = this#
|
||||
<Unresolved name: yield>#(String())
|
||||
this#.<Unresolved name: yield>#(String())
|
||||
(this# as R|kotlin/sequences/SequenceScope<kotlin/String>|)
|
||||
<Unresolved name: yield>#(String())
|
||||
^ this#.<Unresolved name: yield>#(String())
|
||||
}
|
||||
)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FULL_JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
val someMap = WeakHashMap<Any?, Any?>()
|
||||
|
||||
fun foo() {
|
||||
someMap[""]
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
FILE: weakHashMap.kt
|
||||
public final val someMap: R|java/util/WeakHashMap<kotlin/Any?, kotlin/Any?>| = R|java/util/WeakHashMap.WeakHashMap|<R|kotlin/Any?|, R|kotlin/Any?|>()
|
||||
public get(): R|java/util/WeakHashMap<kotlin/Any?, kotlin/Any?>|
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
R|/someMap|.R|FakeOverride<java/util/WeakHashMap.get: R|kotlin/Any?|>|(String())
|
||||
}
|
||||
Reference in New Issue
Block a user