Add test methods and data for uncommon cases

Uncommon means mostly that aren't present in raw fir builder data
This commit is contained in:
Ivan Cilcic
2019-08-15 13:45:22 +03:00
committed by Mikhail Glukhikh
parent 8047aa22a4
commit aebe8c36f5
15 changed files with 474 additions and 0 deletions
@@ -0,0 +1,89 @@
package p
class A {
// Int Int
// │ │
val aProp = 10
}
class B {
// Int Int
// │ │
val bProp = 1
}
fun foo(a: Int, b: Int): Int {
// fun <T, R> with(A, A.() -> Int): Int
// │ constructor A()
// │ │ with@0
// │ │ │
with(A()) {
// this@0
// val (A).aProp: Int
// │
aProp
// fun <T, R> with(B, B.() -> Int): Int
// │ constructor B()
// │ │ with@1
// │ │ │
with(B()) {
// this@0
// val (A).aProp: Int
// │
aProp
// this@1
// val (B).bProp: Int
// │
bProp
// this@0
// val (A).aProp: Int
// │
aProp
}
}
// fun <T, R> with(A, A.() -> Int): Int
// │ constructor A()
// │ │ with@0
// │ │ │
with(A()) {
// this@0
// val (A).aProp: Int
// │
aProp
// fun <T, R> with(B, B.() -> Int): Int
// │ constructor B()
// │ │ with@1
// │ │ │
with(B()) {
// this@0
// val (A).aProp: Int
// │
aProp
// this@1
// val (B).bProp: Int
// │
bProp
}
// fun <T, R> with(B, B.() -> Int): Int
// │ constructor B()
// │ │ with@1
// │ │ │
with(B()) {
// this@0
// val (A).aProp: Int
// │
aProp
// this@1
// val (B).bProp: Int
// │
bProp
}
}
// foo.a: Int
// │
return a
}
@@ -0,0 +1,33 @@
package org.jetbrains.kotlin.test
// collections/List<Int>
// │ fun <T> collections/listOf(vararg Int): collections/List<Int>
// │ │ Int
// │ │ │ Int
// │ │ │ │ Int
// │ │ │ │ │
val listOfInt = listOf(1, 2, 3)
// java/util/ArrayList<Int>
// │ package java
// │ │ constructor util/ArrayList<E : Any!>()
// │ │ │
val javaList = java.util.ArrayList<Int>()
// package java
// │ package java/util
// │ │
fun move(): java.util.ArrayList<Int> {
// val listOfInt: collections/List<Int>
// │
for (elem in listOfInt) {
// val javaList: java/util/ArrayList<Int>
// │ fun (java/util/ArrayList<Int>).add(Int): Boolean
// │ │ val move.elem: Int
// │ │ │
javaList.add(elem)
}
// val javaList: java/util/ArrayList<Int>
// │
return javaList
}
@@ -0,0 +1,81 @@
package org.jetbrains.kotlin.test
// Int Int
// │ │
val p1 = 10
// Double Double
// │ │
val p2: Double = 1.0
// Float Float
// │ │
val p3: Float = 2.5f
// String
// │
val p4 = "some string"
// Double
// │ val p1: Int
// │ │ fun (Int).plus(Double): Double
// │ │ │ val p2: Double
// │ │ │ │
val p5 = p1 + p2
// Double
// │ val p1: Int
// │ │ fun (Int).times(Double): Double
// │ │ │ val p2: Double
// │ │ │ │ fun (Double).plus(Double): Double
// │ │ │ │ │ val p5: Double
// │ │ │ │ │ │ fun (Double).minus(Float): Double
// │ │ │ │ │ │ │ val p3: Float
// │ │ │ │ │ │ │ │
val p6 = p1 * p2 + (p5 - p3)
// Float
// │
val withGetter
// val p1: Int
// │ fun (Int).times(Float): Float
// │ │ val p3: Float
// │ │ │
get() = p1 * p3
// String
// │
var withSetter
// val p4: String
// │
get() = p4
// <set-withSetter>.value: String
// │
set(value) = value
// Boolean
// │
val withGetter2: Boolean
get() {
// Boolean
// │
return true
}
// String
// │
var withSetter2: String
get() = "1"
set(value) {
// var <set-withSetter2>.field: String
// │ <set-withSetter2>.value: String
// │ │ fun (String).plus(Any?): String
// │ │ │
field = value + "!"
}
// String
// │
private val privateGetter: String = "cba"
get
// String
// │
var privateSetter: String = "abc"
private set
@@ -0,0 +1,24 @@
package org.jetbrains.kotlin.test
abstract class Base<T>(var x: T) {
fun replace(newValue: T)
}
// constructor Base<T>(Int)
// │
class Derived(var x: Int): Base<Int>() {
override fun replace(newValue: Int) {
// var (Derived).x: Int
// │ Derived.replace.newValue: Int
// │ │
x = newValue
}
}
fun test() {
// constructor Derived(Int)
// │ fun (Derived).replace(Int): Unit
// │ Int │ Int
// │ │ │ │
Derived(10).replace(20)
}
@@ -0,0 +1,24 @@
interface Source<out T> {
fun nextT(): T
}
fun demo(strs: Source<String>) {
// Source<Any> demo.strs: Source<String>
// │ │
val objects: Source<Any> = strs
}
interface Comparable<in T> {
operator fun compareTo(other: T): Int
}
fun demo(x: Comparable<Number>) {
// demo.x: Comparable<Number>
// │ fun (Comparable<Number>).compareTo(Number): Int
// │ │ Double
// │ │ │
x.compareTo(1.0)
// Comparable<Double> demo.x: Comparable<Number>
// │ │
val y: Comparable<Double> = x
}
@@ -0,0 +1,28 @@
// collections/List<T> collections/List<String>
// │ │
fun <T> copyWhenGreater(list: List<T>, threshold: T): List<String>
where T : CharSequence,
T : Comparable<T> {
// copyWhenGreater.list: collections/List<T>
// │ fun <T> collections/Iterable<T>.filter((T) -> Boolean): collections/List<T>
// │ │ copyWhenGreater.<anonymous>.it: T
// │ │ │ fun (Comparable<T>).compareTo(T): Int
// │ │ │ │ copyWhenGreater.threshold: T
// │ │ │ │ │ fun <T, R> collections/Iterable<T>.map((T) -> String): collections/List<String>
// │ │ │ │ │ │ copyWhenGreater.<anonymous>.it: T
// │ │ │ │ │ │ │ fun (Any).toString(): String
// │ │ │ │ │ │ │ │
return list.filter { it > threshold }.map { it.toString() }
}
fun main() {
// collections/List<String>
// │ fun <T> collections/listOf(vararg String): collections/List<String>
// │ │
val list = listOf("1", "2", "3")
// collections/List<String>
// │ fun <T : CharSequence> copyWhenGreater(collections/List<String>, String): collections/List<String> where copyWhenGreater.T : Comparable<String>
// │ │ val main.list: collections/List<String>
// │ │ │
val copy = copyWhenGreater(list, "2")
}