Move FIR tests to fir modules

This commit is contained in:
Simon Ogorodnik
2018-12-27 20:34:20 +03:00
committed by Mikhail Glukhikh
parent 95af0268b8
commit cfb446df9e
129 changed files with 129 additions and 84 deletions
+22 -2
View File
@@ -17,9 +17,29 @@ dependencies {
compile(project(":compiler:fir:tree"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "annotations") }
testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "idea_rt", "util", "asm-all", rootProject = rootProject) }
testRuntime(intellijDep())
testCompile(commonDep("junit:junit"))
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
testCompile(projectTests(":compiler:tests-common"))
testCompileOnly(project(":kotlin-reflect-api"))
testRuntime(project(":kotlin-reflect"))
}
sourceSets {
"main" { projectDefault() }
"test" {}
}
"test" { projectDefault() }
}
projectTest {
workingDir = rootDir
}
testsJar()
+4
View File
@@ -0,0 +1,4 @@
open class A
class B : A()
+9
View File
@@ -0,0 +1,9 @@
FILE: F.kt
public open class A {
public constructor(): super<R|kotlin/Any|>()
}
public final class B : R|A| {
public constructor(): super<R|A|>()
}
@@ -0,0 +1,9 @@
abstract class A {
abstract class Nested
}
typealias TA = A
class B : TA() {
class NestedInB : Nested()
}
@@ -0,0 +1,20 @@
FILE: NestedOfAliasedType.kt
public abstract class A {
public constructor(): super<R|kotlin/Any|>()
public abstract class Nested {
public constructor(): super<R|kotlin/Any|>()
}
}
public final typealias TA = R|A|
public final class B : R|TA = A| {
public constructor(): super<R|TA = A|>()
public final class NestedInB : R|A.Nested| {
public constructor(): super<R|A.Nested|>()
}
}
@@ -0,0 +1,13 @@
package p
abstract class My {
abstract class NestedOne : My() {
abstract class NestedTwo : NestedOne() {
}
}
}
class Your : My() {
class NestedThree : NestedOne()
}
@@ -0,0 +1,24 @@
FILE: NestedSuperType.kt
public abstract class My {
public constructor(): super<R|kotlin/Any|>()
public abstract class NestedOne : R|p/My| {
public constructor(): super<R|p/My|>()
public abstract class NestedTwo : R|p/My.NestedOne| {
public constructor(): super<R|p/My.NestedOne|>()
}
}
}
public final class Your : R|p/My| {
public constructor(): super<R|p/My|>()
public final class NestedThree : R|p/My.NestedOne| {
public constructor(): super<R|p/My.NestedOne|>()
}
}
@@ -0,0 +1,6 @@
package p
open class A
class B : A()
@@ -0,0 +1,9 @@
FILE: TwoDeclarationsInSameFile.kt
public open class A {
public constructor(): super<R|kotlin/Any|>()
}
public final class B : R|p/A| {
public constructor(): super<R|p/A|>()
}
@@ -0,0 +1,5 @@
abstract class MyStringList : List<String>
abstract class MyMutableStringList : MutableList<String>
fun List<String>.convert(): MyStringList = this as MyStringList
fun ret(l: MutableList<String>): MyMutableStringList = this as MyMutableStringList
@@ -0,0 +1,15 @@
FILE: lists.kt
public abstract class MyStringList : R|kotlin/collections/List<kotlin/String>| {
public constructor(): super<R|kotlin/Any|>()
}
public abstract class MyMutableStringList : R|kotlin/collections/MutableList<kotlin/String>| {
public constructor(): super<R|kotlin/Any|>()
}
public final function convert R|kotlin/collections/List<kotlin/String>|.(): R|MyStringList| {
STUB
}
public final function ret(l: R|kotlin/collections/MutableList<kotlin/String>|): R|MyMutableStringList| {
STUB
}
+17
View File
@@ -0,0 +1,17 @@
package test
abstract class Some {
companion object {
class InCompanion
}
abstract val x: InCompanion
}
abstract class Another {
companion object NamedCompanion {
class InCompanion
}
abstract val x: InCompanion
}
+35
View File
@@ -0,0 +1,35 @@
FILE: companion.kt
public abstract class Some {
public constructor(): super<R|kotlin/Any|>()
public final companion object Companion {
public constructor(): super<R|kotlin/Any|>()
public final class InCompanion {
public constructor(): super<R|kotlin/Any|>()
}
}
public abstract property x(val): R|test/Some.Companion.InCompanion|
public get(): R|test/Some.Companion.InCompanion|
}
public abstract class Another {
public constructor(): super<R|kotlin/Any|>()
public final companion object NamedCompanion {
public constructor(): super<R|kotlin/Any|>()
public final class InCompanion {
public constructor(): super<R|kotlin/Any|>()
}
}
public abstract property x(val): R|test/Another.NamedCompanion.InCompanion|
public get(): R|test/Another.NamedCompanion.InCompanion|
}
+5
View File
@@ -0,0 +1,5 @@
open class Base<T>(val x: T)
class Derived<T : Any>(x: T) : Base<T>(x)
fun <T : Any> create(x: T): Derived<T> = Derived(x)
+15
View File
@@ -0,0 +1,15 @@
FILE: derivedClass.kt
<T> public open class Base {
public constructor(x: R|T|): super<R|kotlin/Any|>()
public final property x(val): R|T|
public get(): R|T|
}
<T : R|kotlin/Any|> public final class Derived : R|Base<T>| {
public constructor(x: R|T|): super<R|Base<T>|>()
}
<T : R|kotlin/Any|> public final function create(x: R|T|): R|Derived<T>| {
STUB
}
+16
View File
@@ -0,0 +1,16 @@
interface Some
object O1 : Some
object O2 : Some
enum class SomeEnum(val x: Some) {
FIRST(O1) {
override fun check(y: Some): Boolean = true
},
SECOND(O2) {
override fun check(y: Some): Boolean = y == O2
};
abstract fun check(y: Some): Boolean
}
+38
View File
@@ -0,0 +1,38 @@
FILE: enum.kt
public abstract interface Some {
}
public final object O1 : R|Some| {
public constructor(): super<R|kotlin/Any|>()
}
public final object O2 : R|Some| {
public constructor(): super<R|kotlin/Any|>()
}
public final enum class SomeEnum {
private constructor(x: R|Some|): super<R|kotlin/Enum|>()
public final property x(val): R|Some|
public get(): R|Some|
public final enum entry FIRST : R|SomeEnum| {
public constructor(): super<R|SomeEnum|>()
public final override function check(y: R|Some|): R|kotlin/Boolean| {
STUB
}
}
public final enum entry SECOND : R|SomeEnum| {
public constructor(): super<R|SomeEnum|>()
public final override function check(y: R|Some|): R|kotlin/Boolean| {
STUB
}
}
public abstract function check(y: R|Some|): R|kotlin/Boolean|
}
@@ -0,0 +1,11 @@
package a.b
class C<T, out S> {
inner class D<R, in P> {
}
}
interface Test {
val x: a.b.C<out CharSequence, *>.D<in List<*>, *>
}
@@ -0,0 +1,15 @@
FILE: complexTypes.kt
<T, out S> public final class C {
public constructor(): super<R|kotlin/Any|>()
<R, in P> public final inner class D {
public constructor(): super<R|kotlin/Any|>()
}
}
public abstract interface Test {
public abstract property x(val): R|a/b/C.D<out kotlin/CharSequence, *, in kotlin/collections/List<*>, *>|
public get(): R|a/b/C.D<out kotlin/CharSequence, *, in kotlin/collections/List<*>, *>|
}
@@ -0,0 +1,33 @@
import my.println
enum class Order {
FIRST,
SECOND,
THIRD
}
enum class Planet(val m: Double, internal val r: Double) {
MERCURY(1.0, 2.0) {
override fun sayHello() {
println("Hello!!!")
}
},
VENERA(3.0, 4.0) {
override fun sayHello() {
println("Ola!!!")
}
},
EARTH(5.0, 6.0) {
override fun sayHello() {
println("Privet!!!")
}
};
val g: Double = G * m / (r * r)
abstract fun sayHello()
companion object {
const val G = 6.67e-11
}
}
@@ -0,0 +1,67 @@
FILE: enums.kt
public final enum class Order {
private constructor(): super<R|kotlin/Enum|>()
public final enum entry FIRST {
public constructor(): super<R|kotlin/Any|>()
}
public final enum entry SECOND {
public constructor(): super<R|kotlin/Any|>()
}
public final enum entry THIRD {
public constructor(): super<R|kotlin/Any|>()
}
}
public final enum class Planet {
private constructor(m: R|kotlin/Double|, r: R|kotlin/Double|): super<R|kotlin/Enum|>()
public final property m(val): R|kotlin/Double|
public get(): R|kotlin/Double|
internal final property r(val): R|kotlin/Double|
internal get(): R|kotlin/Double|
public final enum entry MERCURY : R|Planet| {
public constructor(): super<R|Planet|>()
public final override function sayHello(): R|kotlin/Unit| {
}
}
public final enum entry VENERA : R|Planet| {
public constructor(): super<R|Planet|>()
public final override function sayHello(): R|kotlin/Unit| {
}
}
public final enum entry EARTH : R|Planet| {
public constructor(): super<R|Planet|>()
public final override function sayHello(): R|kotlin/Unit| {
}
}
public final property g(val): R|kotlin/Double| = STUB
public get(): R|kotlin/Double|
public abstract function sayHello(): R|kotlin/Unit|
public final companion object Companion {
public constructor(): super<R|kotlin/Any|>()
public final const property G(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
public get(): R|error: Not supported: FirImplicitTypeImpl|
}
}
@@ -0,0 +1,9 @@
class NoPrimary {
val x: String
constructor(x: String) {
this.x = x
}
constructor(): this("")
}
@@ -0,0 +1,11 @@
FILE: noPrimaryConstructor.kt
public final class NoPrimary {
public final property x(val): R|kotlin/String|
public get(): R|kotlin/String|
public constructor(x: R|kotlin/String|): super<R|kotlin/Any|>() {
}
public constructor(): this<R|NoPrimary|>()
}
@@ -0,0 +1,21 @@
interface SomeInterface {
fun foo(x: Int, y: String): String
val bar: Boolean
}
class SomeClass : SomeInterface {
private val baz = 42
override fun foo(x: Int, y: String): String {
return y + x + baz
}
override var bar: Boolean
get() = true
set(value) {}
lateinit var fau: Double
}
inline class InlineClass
@@ -0,0 +1,33 @@
FILE: simpleClass.kt
public abstract interface SomeInterface {
public abstract function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String|
public abstract property bar(val): R|kotlin/Boolean|
public get(): R|kotlin/Boolean|
}
public final class SomeClass : R|SomeInterface| {
public constructor(): super<R|kotlin/Any|>()
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
private get(): R|error: Not supported: FirImplicitTypeImpl|
public final override function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String| {
}
public final override property bar(var): R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
STUB
}
public set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
}
public final lateinit property fau(var): R|kotlin/Double|
public get(): R|kotlin/Double|
public set(value: R|kotlin/Double|): R|kotlin/Unit|
}
public final inline class InlineClass {
public constructor(): super<R|kotlin/Any|>()
}
@@ -0,0 +1,16 @@
interface List<out T : Any> {
operator fun get(index: Int): T
infix fun concat(other: List<T>): List<T>
}
typealias StringList = List<out String>
typealias AnyList = List<*>
abstract class AbstractList<out T : Any> : List<T>
class SomeList : AbstractList<Int>() {
override fun get(index: Int): Int = 42
override fun concat(other: List<Int>): List<Int> = this
}
@@ -0,0 +1,25 @@
FILE: typeParameters.kt
<out T : R|kotlin/Any|> public abstract interface List {
public abstract operator function get(index: R|kotlin/Int|): R|T|
public abstract infix function concat(other: R|List<T>|): R|List<T>|
}
public final typealias StringList = R|List<out kotlin/String>|
public final typealias AnyList = R|List<*>|
<out T : R|kotlin/Any|> public abstract class AbstractList : R|List<T>| {
public constructor(): super<R|kotlin/Any|>()
}
public final class SomeList : R|AbstractList<kotlin/Int>| {
public constructor(): super<R|AbstractList<kotlin/Int>|>()
public final override function get(index: R|kotlin/Int|): R|kotlin/Int| {
STUB
}
public final override function concat(other: R|List<kotlin/Int>|): R|List<kotlin/Int>| {
STUB
}
}
+6
View File
@@ -0,0 +1,6 @@
interface KMutableProperty1<T> : KProperty1<T>
interface KProperty1<T> : (T) -> Int
+5
View File
@@ -0,0 +1,5 @@
FILE: ft.kt
<T> public abstract interface KMutableProperty1 : R|KProperty1<T>| {
}
<T> public abstract interface KProperty1 : R|(T) -> kotlin/Int| {
}
+16
View File
@@ -0,0 +1,16 @@
fun <T> simpleRun(f: (T) -> Unit): Unit = f()
fun <T, R> List<T>.simpleMap(f: (T) -> R): R {
}
fun <T> simpleWith(t: T, f: T.() -> Unit): Unit = t.f()
interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R>
interface KProperty1<T, out R> : KProperty<R>, (T) -> R
interface KProperty<out R>
interface KMutableProperty<R>
+17
View File
@@ -0,0 +1,17 @@
FILE: functionTypes.kt
<T> public final function simpleRun(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
STUB
}
<T, R> public final function simpleMap R|kotlin/collections/List<T>|.(f: R|(T) -> R|): R|R| {
}
<T> public final function simpleWith(t: R|T|, f: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
STUB
}
<T, R> public abstract interface KMutableProperty1 : R|KProperty1<T, R>|, R|KMutableProperty<R>| {
}
<T, out R> public abstract interface KProperty1 : R|KProperty<R>|, R|(T) -> R| {
}
<out R> public abstract interface KProperty {
}
<R> public abstract interface KMutableProperty {
}
@@ -0,0 +1,7 @@
interface Any
inline fun <reified T : Any> Any.safeAs(): T? = this as? T
abstract class Summator {
abstract fun <T> plus(first: T, second: T): T
}
@@ -0,0 +1,12 @@
FILE: genericFunctions.kt
public abstract interface Any {
}
<reified T : R|Any|> public final inline function safeAs R|Any|.(): R|T| {
STUB
}
public abstract class Summator {
public constructor(): super<R|Any|>()
<T> public abstract function plus(first: R|T|, second: R|T|): R|T|
}
@@ -0,0 +1,10 @@
package annotations
@Target(AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.PROPERTY_GETTER)
annotation class Simple
annotation class WithInt(val value: Int)
annotation class WithString(val s: String)
annotation class Complex(val wi: WithInt, val ws: WithString)
@@ -0,0 +1,28 @@
@file:Simple
package test
import annotations.*
@WithInt(42)
abstract class First {
@Simple
abstract fun foo(@WithString("abc") arg: @Simple Double)
@Complex(WithInt(7), WithString(""))
abstract val v: String
}
@WithString("xyz")
class Second(val y: Char) : @WithInt(0) First() {
override fun foo(arg: Double) {
}
override val v: String
@Simple get() = ""
@WithString("constructor")
constructor(): this('\n')
}
@WithInt(24)
typealias Third = @Simple Second
@@ -0,0 +1,29 @@
FILE: Annotations.kt
@FILE:R|annotations/Simple|()
@R|annotations/WithInt|(STUB) public abstract class First {
public constructor(): super<R|kotlin/Any|>()
@R|annotations/Simple|() public abstract function foo(@R|annotations/WithString|(STUB) arg: @R|annotations/Simple|() R|kotlin/Double|): R|kotlin/Unit|
@R|annotations/Complex|(STUB, STUB) public abstract property v(val): R|kotlin/String|
public get(): R|kotlin/String|
}
@R|annotations/WithString|(STUB) public final class Second : @R|annotations/WithInt|(STUB) R|test/First| {
public constructor(y: R|kotlin/Char|): super<@R|annotations/WithInt|(STUB) R|test/First|>()
public final property y(val): R|kotlin/Char|
public get(): R|kotlin/Char|
public final override function foo(arg: R|kotlin/Double|): R|kotlin/Unit| {
}
public final override property v(val): R|kotlin/String|
@R|annotations/Simple|() public get(): R|kotlin/String| {
STUB
}
@R|annotations/WithString|(STUB) public constructor(): this<R|test/Second|>()
}
@R|annotations/WithInt|(STUB) @R|annotations/WithInt|(STUB) public final typealias Third = @R|annotations/Simple|() R|test/Second|
@@ -0,0 +1,7 @@
package b
import c.C
open class B : C() {
open class NestedInB : NestedInC()
}
@@ -0,0 +1,5 @@
package c
open class C {
open class NestedInC
}
@@ -0,0 +1,8 @@
package a
import b.B
class A : B() {
class NestedInA1 : NestedInB()
class NestedInA2 : NestedInC()
}
@@ -0,0 +1,15 @@
FILE: NestedSuperType.kt
public final class A : R|b/B| {
public constructor(): super<R|b/B|>()
public final class NestedInA1 : R|b/B.NestedInB| {
public constructor(): super<R|b/B.NestedInB|>()
}
public final class NestedInA2 : R|c/C.NestedInC| {
public constructor(): super<R|c/C.NestedInC|>()
}
}
@@ -0,0 +1,7 @@
package b
class A
typealias TA = A
// analyzePriority: 1
@@ -0,0 +1,7 @@
package a
import b.TA
class MyClass : TA()
// analyzePriority: 0
@@ -0,0 +1,5 @@
FILE: TypeAliasExpansion.kt
public final class MyClass : R|b/TA = b/A| {
public constructor(): super<R|b/TA = b/A|>()
}
@@ -0,0 +1,7 @@
package test
sealed class Test {
object O : Test()
class Extra(val x: Int): Test
}
@@ -0,0 +1,11 @@
package other
import test.Test.*
abstract class Factory {
abstract fun createTest(): Test
abstract fun createObj(): O
abstract fun createExtra(): Extra
}
@@ -0,0 +1,11 @@
FILE: sealedStarImport.kt
public abstract class Factory {
public constructor(): super<R|kotlin/Any|>()
public abstract function createTest(): R|error: Symbol not found|
public abstract function createObj(): R|test/Test.O|
public abstract function createExtra(): R|test/Test.Extra|
}
@@ -0,0 +1,3 @@
package b
abstract class MyClass
@@ -0,0 +1,4 @@
package a
import b.MyClass as HisClass
class YourClass : HisClass()
@@ -0,0 +1,5 @@
FILE: simpleAliasedImport.kt
public final class YourClass : R|b/MyClass| {
public constructor(): super<R|b/MyClass|>()
}
@@ -0,0 +1,3 @@
package b
abstract class MyClass
@@ -0,0 +1,4 @@
package a
import b.MyClass
class YourClass : MyClass()
@@ -0,0 +1,5 @@
FILE: simpleImport.kt
public final class YourClass : R|b/MyClass| {
public constructor(): super<R|b/MyClass|>()
}
@@ -0,0 +1,5 @@
package a
class MyClass {
open class MyNested
}
@@ -0,0 +1,5 @@
package b
import a.MyClass.MyNested
class YourClass : MyNested()
@@ -0,0 +1,5 @@
FILE: simpleImportNested.kt
public final class YourClass : R|a/MyClass.MyNested| {
public constructor(): super<R|a/MyClass.MyNested|>()
}
@@ -0,0 +1,5 @@
package a
class Outer {
open class Nested
}
@@ -0,0 +1,5 @@
package b
import a.Outer
class My : Outer.Nested()
@@ -0,0 +1,5 @@
FILE: simpleImportOuter.kt
public final class My : R|a/Outer.Nested| {
public constructor(): super<R|a/Outer.Nested|>()
}
@@ -0,0 +1,5 @@
package b.d
expect interface Other
expect class Another
@@ -0,0 +1,5 @@
package a.d
import b.d.*
fun foo(arg: Other): Another
@@ -0,0 +1,2 @@
FILE: simpleStarImport.kt
public final function foo(arg: R|b/d/Other|): R|b/d/Another|
+7
View File
@@ -0,0 +1,7 @@
abstract class Base(val s: String)
class Outer {
class Derived(s: String) : Base(s)
object Obj : Base("")
}
+22
View File
@@ -0,0 +1,22 @@
FILE: nestedClass.kt
public abstract class Base {
public constructor(s: R|kotlin/String|): super<R|kotlin/Any|>()
public final property s(val): R|kotlin/String|
public get(): R|kotlin/String|
}
public final class Outer {
public constructor(): super<R|kotlin/Any|>()
public final class Derived : R|Base| {
public constructor(s: R|kotlin/String|): super<R|Base|>()
}
public final object Obj : R|Base| {
public constructor(): super<R|Base|>()
}
}
+19
View File
@@ -0,0 +1,19 @@
interface SomeInterface {
fun foo(x: Int, y: String): String
val bar: Boolean
}
class SomeClass : SomeInterface {
private val baz = 42
override fun foo(x: Int, y: String): String {
return y + x + baz
}
override var bar: Boolean
get() = true
set(value) {}
var fau: Double
}
+29
View File
@@ -0,0 +1,29 @@
FILE: simpleClass.kt
public abstract interface SomeInterface {
public abstract function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String|
public abstract property bar(val): R|kotlin/Boolean|
public get(): R|kotlin/Boolean|
}
public final class SomeClass : R|SomeInterface| {
public constructor(): super<R|kotlin/Any|>()
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
private get(): R|error: Not supported: FirImplicitTypeImpl|
public final override function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String| {
}
public final override property bar(var): R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
STUB
}
public set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
}
public final property fau(var): R|kotlin/Double|
public get(): R|kotlin/Double|
public set(value: R|kotlin/Double|): R|kotlin/Unit|
}
@@ -0,0 +1,5 @@
interface B
typealias C = B
class D : C
@@ -0,0 +1,8 @@
FILE: simpleTypeAlias.kt
public abstract interface B {
}
public final typealias C = R|B|
public final class D : R|C = B| {
public constructor(): super<R|kotlin/Any|>()
}
@@ -0,0 +1,5 @@
@Volatile
var xx: Int = 2
@Synchronized
fun foo() {}
@@ -0,0 +1,6 @@
FILE: concurrent.kt
@R|kotlin/jvm/Volatile|() public final property xx(var): R|kotlin/Int| = STUB
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
@R|kotlin/jvm/Synchronized|() public final function foo(): R|kotlin/Unit| {
}
@@ -0,0 +1,9 @@
import kotlin.jvm.functions.Function0
val x: Function0<Int> = { 42 }
val y: Function1<String, String> = { it }
class MyFunction : Function2<Int, String, Unit> {
override fun invoke(p1: Int, p2: String) {}
}
@@ -0,0 +1,12 @@
FILE: functionX.kt
public final property x(val): R|kotlin/jvm/functions/Function0<kotlin/Int>| = STUB
public get(): R|kotlin/jvm/functions/Function0<kotlin/Int>|
public final property y(val): R|kotlin/Function1<kotlin/String, kotlin/String>| = STUB
public get(): R|kotlin/Function1<kotlin/String, kotlin/String>|
public final class MyFunction : R|kotlin/Function2<kotlin/Int, kotlin/String, kotlin/Unit>| {
public constructor(): super<R|kotlin/Any|>()
public final override function invoke(p1: R|kotlin/Int|, p2: R|kotlin/String|): R|kotlin/Unit| {
}
}
@@ -0,0 +1,5 @@
import kotlin.reflect.KClass
val javaClass: Class<String> = String::class.java
val kotlinClass: KClass<String> = String::class
@@ -0,0 +1,5 @@
FILE: reflectionClass.kt
public final property javaClass(val): R|java/lang/Class<kotlin/String>| = STUB
public get(): R|java/lang/Class<kotlin/String>|
public final property kotlinClass(val): R|kotlin/reflect/KClass<kotlin/String>| = STUB
public get(): R|kotlin/reflect/KClass<kotlin/String>|
+3
View File
@@ -0,0 +1,3 @@
import java.util.*
val x: SortedSet<Int> = TreeSet()
+3
View File
@@ -0,0 +1,3 @@
FILE: treeSet.kt
public final property x(val): R|java/util/SortedSet<kotlin/Int>| = STUB
public get(): R|java/util/SortedSet<kotlin/Int>|
@@ -0,0 +1,7 @@
open class A
interface B<S, T : A>
class D : C<A>
typealias C<T> = B<T, A>
@@ -0,0 +1,12 @@
FILE: typeAliasWithGeneric.kt
public open class A {
public constructor(): super<R|kotlin/Any|>()
}
<S, T : R|A|> public abstract interface B {
}
public final class D : R|C<A> = B<T, A>| {
public constructor(): super<R|kotlin/Any|>()
}
<T> public final typealias C = R|B<T, A>|
@@ -0,0 +1 @@
val <T: Any> T.self: T get() = this
@@ -0,0 +1,5 @@
FILE: typeParameterInPropertyReceiver.kt
<T : R|kotlin/Any|> public final property self R|T|.(val): R|T|
public get(): R|T| {
STUB
}
@@ -0,0 +1,17 @@
package test
interface Some
abstract class My<T : Some> {
inner class T
abstract val x: T
abstract fun foo(arg: T)
abstract val y: My.T
abstract val z: test.My.T
class Some : T()
}
@@ -0,0 +1,28 @@
FILE: typeParameterVsNested.kt
public abstract interface Some {
}
<T : R|test/Some|> public abstract class My {
public constructor(): super<R|kotlin/Any|>()
public final inner class T {
public constructor(): super<R|kotlin/Any|>()
}
public abstract property x(val): R|T|
public get(): R|T|
public abstract function foo(arg: R|T|): R|kotlin/Unit|
public abstract property y(val): R|test/My.T|
public get(): R|test/My.T|
public abstract property z(val): R|test/My.T|
public get(): R|test/My.T|
public final class Some : R|test/My.T| {
public constructor(): super<R|T|>()
}
}
@@ -0,0 +1,72 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveTransformer
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.resolve.FirProvider
import org.jetbrains.kotlin.fir.resolve.impl.*
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
abstract class AbstractFirResolveTestCase : AbstractFirResolveWithSessionTestCase() {
override fun createEnvironment(): KotlinCoreEnvironment {
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_NO_RUNTIME)
}
fun doCreateAndProcessFir(ktFiles: List<KtFile>): List<FirFile> {
val session = createSession()
val builder = RawFirBuilder(session)
val transformer = FirTotalResolveTransformer()
val firFiles = ktFiles.map {
val firFile = builder.buildFirFile(it)
(session.service<FirProvider>() as FirProviderImpl).recordFile(firFile)
firFile
}.also {
try {
transformer.processFiles(it)
} catch (e: Exception) {
it.forEach { println(it.render()) }
throw e
}
}
return firFiles
}
fun doTest(path: String) {
val file = File(path)
val allFiles = listOf(file) + file.parentFile.listFiles { sibling ->
sibling.name.removePrefix(file.nameWithoutExtension).removeSuffix(file.extension).matches("\\.[0-9]+\\.".toRegex())
}
val ktFiles =
allFiles.map {
val text = KotlinTestUtils.doLoadFile(it)
it.name to text
}
.sortedBy { (_, text) ->
KotlinTestUtils.parseDirectives(text)["analyzePriority"]?.toInt()
}
.map { (name, text) ->
KotlinTestUtils.createFile(name, text, project)
}
val firFiles = doCreateAndProcessFir(ktFiles)
val firFileDump = StringBuilder().also { firFiles.first().accept(FirRenderer(it), null) }.toString()
val expectedPath = path.replace(".kt", ".txt")
KotlinTestUtils.assertEqualsToFile(File(expectedPath), firFileDump)
}
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.TestJdkKind
abstract class AbstractFirResolveTestCaseWithStdlib : AbstractFirResolveTestCase() {
override fun createEnvironment(): KotlinCoreEnvironment {
return createEnvironmentWithJdk(ConfigurationKind.ALL, TestJdkKind.FULL_JDK)
}
}
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
import org.jetbrains.kotlin.fir.resolve.FirProvider
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
import org.jetbrains.kotlin.fir.resolve.impl.*
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
abstract class AbstractFirResolveWithSessionTestCase : KotlinTestWithEnvironment() {
open fun createSession(): FirSession {
return object : FirSessionBase() {
init {
val firProvider = FirProviderImpl(this)
registerComponent(FirProvider::class, firProvider)
registerComponent(
FirSymbolProvider::class,
FirCompositeSymbolProvider(listOf(firProvider, JavaSymbolProvider(project), FirLibrarySymbolProviderImpl(this)))
)
registerComponent(FirQualifierResolver::class, FirQualifierResolverImpl(this))
registerComponent(FirTypeResolver::class, FirTypeResolverImpl())
}
}
}
}
@@ -0,0 +1,230 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/fir/resolve/testData/resolve")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInResolve() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true, "stdlib");
}
@TestMetadata("companion.kt")
public void testCompanion() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/companion.kt");
}
@TestMetadata("derivedClass.kt")
public void testDerivedClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/derivedClass.kt");
}
@TestMetadata("enum.kt")
public void testEnum() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/enum.kt");
}
@TestMetadata("F.kt")
public void testF() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/F.kt");
}
@TestMetadata("ft.kt")
public void testFt() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/ft.kt");
}
@TestMetadata("functionTypes.kt")
public void testFunctionTypes() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/functionTypes.kt");
}
@TestMetadata("genericFunctions.kt")
public void testGenericFunctions() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/genericFunctions.kt");
}
@TestMetadata("nestedClass.kt")
public void testNestedClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/nestedClass.kt");
}
@TestMetadata("NestedOfAliasedType.kt")
public void testNestedOfAliasedType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/NestedOfAliasedType.kt");
}
@TestMetadata("NestedSuperType.kt")
public void testNestedSuperType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/NestedSuperType.kt");
}
@TestMetadata("simpleClass.kt")
public void testSimpleClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/simpleClass.kt");
}
@TestMetadata("simpleTypeAlias.kt")
public void testSimpleTypeAlias() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/simpleTypeAlias.kt");
}
@TestMetadata("treeSet.kt")
public void testTreeSet() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/treeSet.kt");
}
@TestMetadata("TwoDeclarationsInSameFile.kt")
public void testTwoDeclarationsInSameFile() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/TwoDeclarationsInSameFile.kt");
}
@TestMetadata("typeAliasWithGeneric.kt")
public void testTypeAliasWithGeneric() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/typeAliasWithGeneric.kt");
}
@TestMetadata("typeParameterInPropertyReceiver.kt")
public void testTypeParameterInPropertyReceiver() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/typeParameterInPropertyReceiver.kt");
}
@TestMetadata("typeParameterVsNested.kt")
public void testTypeParameterVsNested() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/typeParameterVsNested.kt");
}
@TestMetadata("compiler/fir/resolve/testData/resolve/builtins")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Builtins extends AbstractFirResolveTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInBuiltins() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/builtins"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("lists.kt")
public void testLists() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/builtins/lists.kt");
}
}
@TestMetadata("compiler/fir/resolve/testData/resolve/fromBuilder")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class FromBuilder extends AbstractFirResolveTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInFromBuilder() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/fromBuilder"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("complexTypes.kt")
public void testComplexTypes() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/fromBuilder/complexTypes.kt");
}
@TestMetadata("enums.kt")
public void testEnums() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/fromBuilder/enums.kt");
}
@TestMetadata("noPrimaryConstructor.kt")
public void testNoPrimaryConstructor() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/fromBuilder/noPrimaryConstructor.kt");
}
@TestMetadata("simpleClass.kt")
public void testSimpleClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/fromBuilder/simpleClass.kt");
}
@TestMetadata("typeParameters.kt")
public void testTypeParameters() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/fromBuilder/typeParameters.kt");
}
}
@TestMetadata("compiler/fir/resolve/testData/resolve/multifile")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multifile extends AbstractFirResolveTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultifile() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/multifile"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("Annotations.kt")
public void testAnnotations() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/Annotations.kt");
}
@TestMetadata("NestedSuperType.kt")
public void testNestedSuperType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/NestedSuperType.kt");
}
@TestMetadata("sealedStarImport.kt")
public void testSealedStarImport() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/sealedStarImport.kt");
}
@TestMetadata("simpleAliasedImport.kt")
public void testSimpleAliasedImport() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/simpleAliasedImport.kt");
}
@TestMetadata("simpleImport.kt")
public void testSimpleImport() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/simpleImport.kt");
}
@TestMetadata("simpleImportNested.kt")
public void testSimpleImportNested() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/simpleImportNested.kt");
}
@TestMetadata("simpleImportOuter.kt")
public void testSimpleImportOuter() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/simpleImportOuter.kt");
}
@TestMetadata("simpleStarImport.kt")
public void testSimpleStarImport() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/simpleStarImport.kt");
}
@TestMetadata("TypeAliasExpansion.kt")
public void testTypeAliasExpansion() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/multifile/TypeAliasExpansion.kt");
}
}
}
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/fir/resolve/testData/resolve/stdlib")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTestCaseWithStdlib {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInStdlib() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("concurrent.kt")
public void testConcurrent() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/concurrent.kt");
}
@TestMetadata("functionX.kt")
public void testFunctionX() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/functionX.kt");
}
@TestMetadata("reflectionClass.kt")
public void testReflectionClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.kt");
}
}