[IR] dumpKotlinLike: add testdata for FIR tests

This commit is contained in:
Zalim Bashorov
2020-11-20 18:18:14 +03:00
committed by teamcityserver
parent d7bd4240e1
commit c68040753d
298 changed files with 12186 additions and 0 deletions
@@ -0,0 +1,17 @@
class MyMap<K : Any, V : Any> : AbstractMutableMap<K, V> {
constructor() /* primary */ {
super/*AbstractMutableMap*/<K, V>()
/* <init>() */
}
override fun put(key: K, value: V): V? {
return null
}
override val entries: MutableSet<MutableEntry<K, V>>
override get(): MutableSet<MutableEntry<K, V>> {
return mutableSetOf<MutableEntry<K, V>>()
}
}
@@ -0,0 +1,31 @@
class ResolvedCall<C : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class MyCandidate {
constructor(resolvedCall: ResolvedCall<*>) /* primary */ {
super/*Any*/()
/* <init>() */
}
val resolvedCall: ResolvedCall<*>
field = resolvedCall
get
}
private fun <A : Any?> allCandidatesResult(allCandidates: Collection<MyCandidate>): OverloadResolutionResultsImpl<A?>? {
return nameNotFound<A?>().apply<OverloadResolutionResultsImpl<A?>?>(block = local fun OverloadResolutionResultsImpl<A?>?.<anonymous>() {
<this>.setAllCandidates(allCandidates = allCandidates.map<MyCandidate, ResolvedCall<A>>(transform = local fun <anonymous>(it: MyCandidate): ResolvedCall<A> {
return it.<get-resolvedCall>() as ResolvedCall<A>
}
))
}
)
}
@@ -0,0 +1,29 @@
annotation class Storage : Annotation {
constructor(value: String) /* primary */
val value: String
field = value
get
}
annotation class State : Annotation {
constructor(name: String, storages: Array<Storage>) /* primary */
val name: String
field = name
get
val storages: Array<Storage>
field = storages
get
}
@State(name = "1", storages = [Storage(value = "HELLO")])
class Test {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
@@ -0,0 +1,12 @@
abstract class BaseFirBuilder<T : Any?> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
inline fun <T : Any?> withCapturedTypeParameters(block: Function0<T>): T {
return block.invoke()
}
}
@@ -0,0 +1,62 @@
interface ComponentContainer {
}
interface PlatformSpecificExtension<S : PlatformSpecificExtension<S>> {
}
interface ComponentDescriptor {
}
abstract class PlatformExtensionsClashResolver<E : PlatformSpecificExtension<E>> {
constructor(applicableTo: Class<E>) /* primary */ {
super/*Any*/()
/* <init>() */
}
val applicableTo: Class<E>
field = applicableTo
get
}
class ClashResolutionDescriptor<E : PlatformSpecificExtension<E>> {
constructor(container: ComponentContainer, resolver: PlatformExtensionsClashResolver<E>, clashedComponents: List<ComponentDescriptor>) /* primary */ {
super/*Any*/()
/* <init>() */
}
private val resolver: PlatformExtensionsClashResolver<E>
field = resolver
private get
private val clashedComponents: List<ComponentDescriptor>
field = clashedComponents
private get
}
private val registrationMap: HashMap<Type, Any>
field = hashMapOf<Type, Any>()
private get
fun resolveClashesIfAny(container: ComponentContainer, clashResolvers: List<PlatformExtensionsClashResolver<*>>) {
{ // BLOCK
val <iterator>: Iterator<PlatformExtensionsClashResolver<*>> = clashResolvers.iterator()
while (<iterator>.hasNext()) { // BLOCK
val resolver: PlatformExtensionsClashResolver<*> = <iterator>.next()
val clashedComponents: Collection<ComponentDescriptor> = { // BLOCK
val <elvis>: Collection<ComponentDescriptor>? = <get-registrationMap>().get(p0 = resolver.<get-applicableTo>()) as? Collection<ComponentDescriptor>
when {
EQEQ(arg0 = <elvis>, arg1 = null) -> continue
else -> <elvis> /*as Collection<ComponentDescriptor> */
}
}
val substituteDescriptor: ClashResolutionDescriptor<out PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out Any?>>>>>> = ClashResolutionDescriptor<PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out PlatformSpecificExtension<out Any?>>>>>>(container = container, resolver = resolver, clashedComponents = clashedComponents.toList<ComponentDescriptor>())
}
}
}
@@ -0,0 +1,77 @@
interface IrType {
}
interface TypeRemapper {
abstract fun enterScope(irTypeParametersContainer: IrTypeParametersContainer)
abstract fun remapType(type: IrType): IrType
abstract fun leaveScope()
}
interface IrTypeParametersContainer : IrDeclaration, IrDeclarationParent {
abstract var typeParameters: List<IrTypeParameter>
abstract get
abstract set
}
interface IrDeclaration {
}
interface IrTypeParameter : IrDeclaration {
abstract val superTypes: MutableList<IrType>
abstract get
}
interface IrDeclarationParent {
}
class DeepCopyIrTreeWithSymbols {
constructor(typeRemapper: TypeRemapper) /* primary */ {
super/*Any*/()
/* <init>() */
}
private val typeRemapper: TypeRemapper
field = typeRemapper
private get
private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter {
return declaration
}
fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) {
<this>.<set-typeParameters>(<set-?> = other.<get-typeParameters>().map<IrTypeParameter, IrTypeParameter>(transform = local fun <anonymous>(it: IrTypeParameter): IrTypeParameter {
return <this>.copyTypeParameter(declaration = it)
}
))
<this>.<get-typeRemapper>().withinScope<Unit>(irTypeParametersContainer = <this>, fn = local fun <anonymous>() {
{ // BLOCK
val <iterator>: Iterator<Pair<IrTypeParameter, IrTypeParameter>> = <this>.<get-typeParameters>().zip<IrTypeParameter, IrTypeParameter>(other = other.<get-typeParameters>()).iterator()
while (<iterator>.hasNext()) { // BLOCK
val <destruct>: Pair<IrTypeParameter, IrTypeParameter> = <iterator>.next()
val thisTypeParameter: IrTypeParameter = <destruct>.component1()
val otherTypeParameter: IrTypeParameter = <destruct>.component2()
otherTypeParameter.<get-superTypes>().mapTo<IrType, IrType, MutableList<IrType>>(destination = thisTypeParameter.<get-superTypes>(), transform = local fun <anonymous>(it: IrType): IrType {
return <this>.<get-typeRemapper>().remapType(type = it)
}
)
}
}
}
)
}
}
inline fun <T : Any?> TypeRemapper.withinScope(irTypeParametersContainer: IrTypeParametersContainer, fn: Function0<T>): T {
<this>.enterScope(irTypeParametersContainer = irTypeParametersContainer)
val result: T = fn.invoke()
<this>.leaveScope()
return result
}
@@ -0,0 +1,60 @@
class Impl : A, B {
constructor(b: B) /* primary */ {
super/*Any*/()
/* <init>() */
<this>.#<$$delegate_0> = b
}
override fun add(element: String?): Boolean {
return <this>.#<$$delegate_0>.add(element = element)
}
override fun addAll(elements: Collection<String?>): Boolean {
return <this>.#<$$delegate_0>.addAll(elements = elements)
}
override fun clear() {
<this>.#<$$delegate_0>.clear()
}
override operator fun iterator(): MutableIterator<String?> {
return <this>.#<$$delegate_0>.iterator()
}
override fun remove(element: String?): Boolean {
return <this>.#<$$delegate_0>.remove(element = element)
}
override fun removeAll(elements: Collection<String?>): Boolean {
return <this>.#<$$delegate_0>.removeAll(elements = elements)
}
override fun retainAll(elements: Collection<String?>): Boolean {
return <this>.#<$$delegate_0>.retainAll(elements = elements)
}
override operator fun contains(element: String?): Boolean {
return <this>.#<$$delegate_0>.contains(element = element)
}
override fun containsAll(elements: Collection<String?>): Boolean {
return <this>.#<$$delegate_0>.containsAll(elements = elements)
}
override fun isEmpty(): Boolean {
return <this>.#<$$delegate_0>.isEmpty()
}
override val size: Int
override get(): Int {
return <this>.#<$$delegate_0>.<get-size>()
}
local /*final field*/ val <$$delegate_0>: B
}
fun box(): String {
return "OK"
}
@@ -0,0 +1,17 @@
open class BaseConverter : BaseFirBuilder<Any> {
constructor() /* primary */ {
super/*BaseFirBuilder*/<Any>()
/* <init>() */
}
}
class DeclarationsConverter : BaseConverter {
constructor() /* primary */ {
super/*BaseConverter*/()
/* <init>() */
}
}
@@ -0,0 +1,49 @@
fun box(): String {
val obj: <no name provided> = { // BLOCK
local class <no name provided> {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val end: String
field = "K"
get
fun foo(): String {
return <this>.Some(s = "O").bar()
}
local inner class Some : Base {
constructor(s: String) /* primary */ {
<this>.super/*Base*/(s = s)
/* <init>() */
}
fun bar(): String {
return <this>.<get-s>().plus(other = <this>.<get-end>())
}
}
local open inner class Base {
constructor(s: String) /* primary */ {
super/*Any*/()
/* <init>() */
}
val s: String
field = s
get
}
}
<no name provided>()
}
return obj.foo()
}
@@ -0,0 +1,67 @@
data class Some<T : Any?> {
constructor(value: T) /* primary */ {
super/*Any*/()
/* <init>() */
}
val value: T
field = value
get
fun component1(): T {
return <this>.#value
}
fun copy(value: T = <this>.#value): Some<T> {
return Some<Any>(value = value)
}
override fun equals(other: Any?): Boolean {
when {
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
}
when {
other !is Some<T> -> return false
}
val tmp0_other_with_cast: Some<T> = other as Some<T>
when {
EQEQ(arg0 = <this>.#value, arg1 = tmp0_other_with_cast.#value).not() -> return false
}
return true
}
override fun hashCode(): Int {
return when {
EQEQ(arg0 = <this>.#value, arg1 = null) -> 0
else -> <this>.#value.hashCode()
}
}
override fun toString(): String {
return "Some(" + "value=" + <this>.#value + ")"
}
}
interface MyList<T : Any?> : List<Some<T>> {
}
open class SomeList<T : Any?> : MyList<T>, ArrayList<Some<T>> {
constructor() /* primary */ {
super/*ArrayList*/<Some<T>>()
/* <init>() */
}
}
class FinalList : SomeList<String> {
constructor() /* primary */ {
super/*SomeList*/<String>()
/* <init>() */
}
}
@@ -0,0 +1,4 @@
fun foo() {
val ref1: KProperty0<String?> = SomeJavaClass::someJavaField/*</* null */>()*/
val ref2: KProperty0<String?> = SomeJavaClass::someJavaField/*</* null */>()*/
}
@@ -0,0 +1,79 @@
typealias Some = Function1<Any, String?>
object Factory {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
fun foo(a: String): String {
return "Alpha"
}
fun foo(a: String, f: Function1<Any, String?>): String {
return "Omega"
}
}
interface Base {
}
interface Delegate : Base {
abstract fun bar()
}
interface Derived : Delegate {
}
data class DataClass : Derived, Delegate {
constructor(delegate: Delegate) /* primary */ {
super/*Any*/()
/* <init>() */
<this>.#<$$delegate_0> = delegate
}
val delegate: Delegate
field = delegate
get
fun component1(): Delegate {
return <this>.#delegate
}
fun copy(delegate: Delegate = <this>.#delegate): DataClass {
return DataClass(delegate = delegate)
}
override fun bar() {
<this>.#<$$delegate_0>.bar()
}
local /*final field*/ val <$$delegate_0>: Delegate
override fun equals(other: Any?): Boolean {
when {
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
}
when {
other !is DataClass -> return false
}
val tmp0_other_with_cast: DataClass = other as DataClass
when {
EQEQ(arg0 = <this>.#delegate, arg1 = tmp0_other_with_cast.#delegate).not() -> return false
}
return true
}
override fun hashCode(): Int {
return <this>.#delegate.hashCode()
}
override fun toString(): String {
return "DataClass(" + "delegate=" + <this>.#delegate + ")"
}
}
@@ -0,0 +1,52 @@
class Candidate {
constructor(symbol: AbstractFirBasedSymbol<*>) /* primary */ {
super/*Any*/()
/* <init>() */
}
val symbol: AbstractFirBasedSymbol<*>
field = symbol
get
}
abstract class AbstractFirBasedSymbol<E> where E : FirSymbolOwner<E>, E : FirDeclaration {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
lateinit var fir: E
get
set
}
interface FirDeclaration {
}
interface FirSymbolOwner<E> where E : FirSymbolOwner<E>, E : FirDeclaration {
abstract val symbol: AbstractFirBasedSymbol<E>
abstract get
}
interface FirCallableMemberDeclaration<F : FirCallableMemberDeclaration<F>> : FirSymbolOwner<F>, FirDeclaration {
abstract override val symbol: AbstractFirBasedSymbol<F>
abstract override get
}
fun foo(candidate: Candidate) {
val me: FirSymbolOwner<out FirSymbolOwner<out FirSymbolOwner<out FirSymbolOwner<out FirSymbolOwner<out Any?>>>>> = candidate.<get-symbol>().<get-fir>()
when {
when {
me is FirCallableMemberDeclaration<*> -> EQEQ(arg0 = me /*as FirCallableMemberDeclaration<*> */.<get-symbol>(), arg1 = null).not()
else -> false
} -> { // BLOCK
}
}
}
@@ -0,0 +1,39 @@
private const val BACKSLASH: Char
field = '\\'
private get
private fun Reader.nextChar(): Char? {
return { // BLOCK
val tmp0_safe_receiver: Int? = <this>.read().takeUnless<Int>(predicate = local fun <anonymous>(it: Int): Boolean {
return EQEQ(arg0 = it, arg1 = -1)
}
)
when {
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
else -> tmp0_safe_receiver.toChar()
}
}
}
fun Reader.consumeRestOfQuotedSequence(sb: StringBuilder, quote: Char) {
var ch: Char? = <this>.nextChar()
while (when {
EQEQ(arg0 = ch, arg1 = null).not() -> EQEQ(arg0 = ch /*as Char */, arg1 = quote).not()
else -> false
}) { // BLOCK
when {
EQEQ(arg0 = ch /*as Char */, arg1 = <get-BACKSLASH>()) -> { // BLOCK
val tmp1_safe_receiver: Char? = <this>.nextChar()
when {
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
else -> tmp1_safe_receiver.let<Char, StringBuilder?>(block = local fun <anonymous>(it: Char): StringBuilder? {
return sb.append(p0 = it)
}
)
}
}
else -> sb.append(p0 = ch /*as Char */)
} /*~> Unit */
ch = <this>.nextChar()
}
}
@@ -0,0 +1,13 @@
class Owner {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
fun <T : Any?> foo(x: T, y: T) {
val map: MutableMap<T, T> = mutableMapOf<T, T>()
map.putIfAbsent(p0 = x, p1 = y) /*~> Unit */
}
}
@@ -0,0 +1,22 @@
interface Something {
}
interface Recursive<R> where R : Recursive<R>, R : Something {
abstract val symbol: AbstractSymbol<R>
abstract get
}
abstract class AbstractSymbol<E> where E : Recursive<E>, E : Something {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
fun foo(list: List<Any>) {
val result: List<AbstractSymbol<out Recursive<*>>> = list.filterIsInstance<Recursive<*>>().map<Recursive<*>, AbstractSymbol<out Recursive<*>>>(transform = Recursive::symbol)
}
}
@@ -0,0 +1,3 @@
fun foo(t: Throwable) {
t.setStackTrace(p0 = t.getStackTrace())
}
@@ -0,0 +1,14 @@
class V8Array {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
fun box(): String {
val array: V8Array = V8Array()
val list: List<String> = toList(array = array) as List<String>
return list.get(index = 0)
}