PSI Pattern Matching: Add equivalence tests for JetPsiUnifier

This commit is contained in:
Alexey Sedunov
2014-07-29 17:15:25 +04:00
parent a3758f9fa3
commit f1c18d0e3f
192 changed files with 3199 additions and 0 deletions
@@ -340,4 +340,9 @@ public fun PsiElement.siblings(forward: Boolean = true, withItself: Boolean = tr
val stepFun = if (forward) { (e: PsiElement) -> e.getNextSibling() } else { (e: PsiElement) -> e.getPrevSibling() }
val stream = stream(this, stepFun)
return if (withItself) stream else stream.drop(1)
}
public fun PsiElement.parents(withItself: Boolean = true): Stream<PsiElement> {
val stream = stream(this) { if (it is PsiFile) null else it.getParent() }
return if (withItself) stream else stream.drop(1)
}
@@ -119,6 +119,7 @@ import org.jetbrains.jet.lang.resolve.java.AbstractJavaTypeSubstitutorTest
import org.jetbrains.jet.plugin.intentions.declarations.AbstractJoinLinesTest
import org.jetbrains.jet.codegen.AbstractScriptCodegenTest
import org.jetbrains.jet.plugin.parameterInfo.AbstractFunctionParameterInfoTest
import org.jetbrains.jet.psi.patternMatching.AbstractJetPsiUnifierTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -309,6 +310,10 @@ fun main(args: Array<String>) {
model("checker/infos", testMethod = "doTestWithInfos")
}
testClass(javaClass<AbstractJetPsiUnifierTest>()) {
model("unifier")
}
testClass(javaClass<AbstractCodeFragmentHighlightingTest>()) {
model("checker/codeFragments", extension = "kt", recursive = false)
model("checker/codeFragments/imports", testMethod = "doTestWithImport", extension = "kt")
@@ -0,0 +1,34 @@
// WITH_RUNTIME
fun foo() {
when {
true -> <selection>{
val a = object: Function0<Int> {
override fun invoke(): Int = 1
}
val b = object: Function0<Int> {
override fun invoke(): Int = a() + 1
}
println(a() - b())
}</selection>
true -> {
val b = object: Function0<Int> {
override fun invoke(): Int = 1
}
val a = object: Function0<Int> {
override fun invoke(): Int = b() + 1
}
println(b() - a())
}
true -> {
val b = object: Function0<Int> {
override fun invoke(): Int = 1
}
val a = object: Function0<Int> {
override fun invoke(): Int = b() + 1
}
println(a() - b())
}
}
}
@@ -0,0 +1,19 @@
{
val a = object: Function0<Int> {
override fun invoke(): Int = 1
}
val b = object: Function0<Int> {
override fun invoke(): Int = a() + 1
}
println(a() - b())
}
{
val b = object: Function0<Int> {
override fun invoke(): Int = 1
}
val a = object: Function0<Int> {
override fun invoke(): Int = b() + 1
}
println(b() - a())
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
fun foo() {
when {
true -> <selection>{
fun a() = 1
fun b() = a() + 1
println(a() - b())
}</selection>
true -> {
fun b() = 1
fun a() = b() + 1
println(b() - a())
}
true -> {
fun b() = 1
fun a() = b() + 1
println(a() - b())
}
}
}
@@ -0,0 +1,11 @@
{
fun a() = 1
fun b() = a() + 1
println(a() - b())
}
{
fun b() = 1
fun a() = b() + 1
println(b() - a())
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
fun foo() {
when {
true -> <selection>{
val a = 1
val b = a + 1
println(a - b)
}</selection>
true -> {
val b = 1
val a = b + 1
println(b - a)
}
true -> {
val b = 1
val a = b + 1
println(a - b)
}
}
}
@@ -0,0 +1,11 @@
{
val a = 1
val b = a + 1
println(a - b)
}
{
val b = 1
val a = b + 1
println(b - a)
}
@@ -0,0 +1,16 @@
fun foo(a: Int) {
@A
while (true) {
@B
while (true) {
if (a > 0) break@A
if (a < 0) <selection>break@B</selection>
}
@B
while (true) {
if (a > 0) break@A
if (a < 0) break@B
}
}
}
@@ -0,0 +1 @@
break@B
@@ -0,0 +1,16 @@
fun foo(a: Int) {
@A
while (true) {
@B
while (true) {
if (a > 0) <selection>continue@A</selection>
if (a < 0) continue@B
}
@B
while (true) {
if (a > 0) continue@A
if (a < 0) continue@B
}
}
}
@@ -0,0 +1,3 @@
continue@A
continue@A
@@ -0,0 +1,24 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
var t = a
<selection>do {
println((t))
t++
} while (t != (a + b))</selection>
var u = a
do {
println(t)
t++
} while (u != a + b)
while (t != a + b) {
println(t)
t++
}
do {
println(t)
t++
} while (t != a + b)
}
@@ -0,0 +1,9 @@
do {
println((t))
t++
} while (t != (a + b))
do {
println(t)
t++
} while (t != a + b)
@@ -0,0 +1,18 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
<selection>for (i in a - b..a + b) {
println(i*i)
}</selection>
for (k in a - b..a + b) {
println(k*k)
}
for (i in a..a + b) {
println(i*i)
}
for (i in (a - b..a + b)) {
println(i*i)
}
}
@@ -0,0 +1,11 @@
for (i in a - b..a + b) {
println(i*i)
}
for (k in a - b..a + b) {
println(k*k)
}
for (i in (a - b..a + b)) {
println(i*i)
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
<selection>if ((a) + b > 0) {
println(a*(b))
}</selection>
println(a*b)
if (a + b > 0) {
println(a*(b))
}
if (a + b > 0) {
println((a*b))
}
else {
println(a + b)
}
}
@@ -0,0 +1,7 @@
if ((a) + b > 0) {
println(a*(b))
}
if (a + b > 0) {
println(a*(b))
}
@@ -0,0 +1,26 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
if ((a) + b > 0) {
println(a*b)
}
println(a*b)
if (a + b > (0)) {
println(a*(b))
}
else {
println(a + b)
}
if (a + b > 0) {
println(a*b)
}
<selection>if (a + (b) > 0) {
println(a*b)
}
else {
println((a + b))
}</selection>
}
@@ -0,0 +1,13 @@
if (a + b > (0)) {
println(a*(b))
}
else {
println(a + b)
}
if (a + (b) > 0) {
println(a*b)
}
else {
println((a + b))
}
@@ -0,0 +1,11 @@
inline fun run(f: () -> Unit) = f()
fun foo(a: Int) {
run {
run {
if (a > 0) <selection>return@foo</selection>
if (a < 0) return
return@foo
}
}
}
@@ -0,0 +1,3 @@
return@foo
return@foo
@@ -0,0 +1,6 @@
fun foo() {
<selection>throw AssertionError()</selection>
throw NullPointerException()
AssertionError()
throw (AssertionError())
}
@@ -0,0 +1,3 @@
throw AssertionError()
throw (AssertionError())
@@ -0,0 +1,6 @@
// DISABLE-ERRORS
fun foo(a: Int) {
if (a > 0) <selection>return</selection>
if (a < 0) return a
return
}
@@ -0,0 +1,3 @@
return
return
@@ -0,0 +1,8 @@
// DISABLE-ERRORS
fun foo(a: Int): Int {
if (a > 0) <selection>return (a) + 1</selection>
if (a < 0) return
if (a == 0) return a
return (a + 1)
return
}
@@ -0,0 +1,3 @@
return (a) + 1
return (a + 1)
@@ -0,0 +1,30 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
<selection>when((a)) {
1 -> println(b)
(2) -> println((a - b))
else -> println(a + b)
}</selection>
when(a) {
1 -> println(b)
2 -> println(a - b)
}
when {
a == 1 -> println(b)
a == 2 -> println(a - b)
else -> println(a + b)
}
when(a) {
1 -> println(b)
2 -> println(a - b)
else -> println(a + b)
}
when(a) {
2 -> println(a - b)
1 -> println(b)
}
}
@@ -0,0 +1,11 @@
when((a)) {
1 -> println(b)
(2) -> println((a - b))
else -> println(a + b)
}
when(a) {
1 -> println(b)
2 -> println(a - b)
else -> println(a + b)
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
<selection>when {
(a == 1) -> println(b)
a == 2 -> println(a - b)
else -> println(a + b)
}</selection>
when {
a == 1 -> println(b)
a == 2 -> println(a - b)
}
when {
a == 1 -> println(b)
(a == 2) -> println((a - b))
else -> println(a + b)
}
when(a) {
2 -> println(a - b)
1 -> println(b)
}
}
@@ -0,0 +1,11 @@
when {
(a == 1) -> println(b)
a == 2 -> println(a - b)
else -> println(a + b)
}
when {
a == 1 -> println(b)
(a == 2) -> println((a - b))
else -> println(a + b)
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) {
var t = a
<selection>while (t != (a + b)) {
println(t)
t++
}</selection>
var u = a
while (u != a + b) {
println(t)
t++
}
do {
println(t)
t++
} while (t != a + b)
while (t != a + b) {
println((t))
t++
}
}
@@ -0,0 +1,9 @@
while (t != (a + b)) {
println(t)
t++
}
while (t != a + b) {
println((t))
t++
}
@@ -0,0 +1,28 @@
fun foo() {
{
val t = <selection>object {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}</selection>
}
{
val v = object {
val x = 1
fun b() = x + 1
val c: Int
get() = b() + 1
}
}
{
val w = object {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
}
}
@@ -0,0 +1,13 @@
object {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
object {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
@@ -0,0 +1,24 @@
fun foo() {
open class Z(p: Int)
trait T;
{
<selection>class A: Z(1), T</selection>
}
{
class B: Z(1), T
}
{
class C: Z(1)
}
{
class D: Z(2), T
}
{
class E: T
}
}
@@ -0,0 +1,3 @@
class A: Z(1), T
class B: Z(1), T
@@ -0,0 +1,25 @@
// DISABLE-ERRORS
fun foo() {
trait T
open class Z(p: Int): T;
{
<selection>class A: T by Z(1)</selection>
}
{
class B: Z(1), T
}
{
class C: Z(1)
}
{
class D: T by Z(1)
}
{
class E: T by Z(2)
}
}
@@ -0,0 +1,3 @@
class A: T by Z(1)
class D: T by Z(1)
@@ -0,0 +1,11 @@
fun foo() {
<selection>class A</selection>
class B {
}
class C {
val n: Int = 1
}
}
@@ -0,0 +1,5 @@
class A
class B {
}
@@ -0,0 +1,56 @@
// DISABLE-ERRORS
fun foo() {
{
<selection>class A(p: Int = 1, val q: Int = p + 1) {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}</selection>
}
{
class B(n: Int = 1, val q: Int = n + 1) {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
}
{
class C {
val x = 1
fun b() = x + 1
val c: Int
get() = b() + 1
}
}
{
class D(n: Int = 1, val m: Int = n + 1) {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
}
{
class E(val n: Int = 1, val q: Int = n + 1) {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
}
{
object F {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
}
}
@@ -0,0 +1,13 @@
class A(p: Int = 1, val q: Int = p + 1) {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
class B(n: Int = 1, val q: Int = n + 1) {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
@@ -0,0 +1,38 @@
// DISABLE-ERRORS
fun foo() {
{
<selection>object A {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}</selection>
}
{
class B {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
}
{
object C {
val x = 1
fun b() = x + 1
val c: Int
get() = b() + 1
}
}
{
object D {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
}
}
@@ -0,0 +1,13 @@
object A {
val a = 1
fun b() = a + 1
val c: Int
get() = b() + 1
}
object D {
fun b() = a + 1
val a = 1
val c: Int
get() = b() + 1
}
@@ -0,0 +1,42 @@
fun foo() {
<selection>{
open class Z<T>(p: T)
trait T
class A: Z<Int>(1), T
}</selection>
{
open class Z<A>(r: A)
trait T
class B: Z<Int>(1), T
}
{
open class T<A>(r: A)
trait Z
class C: T<Int>(1), Z
}
{
open class Z<T>(q: T)
trait T
class D: Z<Int>(2), T
}
{
open class Z<T>(q: T)
class E: Z<Int>(1)
}
{
open class Z<A>(r: A)
trait T
class F: Z<String>("1"), T
}
{
open class Z(r: Int)
trait T
class B: Z(1), T
}
}
@@ -0,0 +1,17 @@
{
open class Z<T>(p: T)
trait T
class A: Z<Int>(1), T
}
{
open class Z<A>(r: A)
trait T
class B: Z<Int>(1), T
}
{
open class T<A>(r: A)
trait Z
class C: T<Int>(1), Z
}
@@ -0,0 +1,137 @@
// DISABLE-ERRORS
fun foo() {
<selection>class A {
fun a(x: Int): Int = b(x) + 1
fun b(y: Int): Int = a(y) - 1
{
println(1)
}
class X
inner class Y
trait T
object O
val p = 1
val q = p + 1
{
println(2)
}
class object {
fun f() = 1
val g = f() - 1
}
}</selection>
class B {
{
println(1)
}
class X
fun b(p: kotlin.Int): kotlin.Int = a(p) - 1
inner class Y
val p = 1
class object {
fun f() = 1
val g = f() - 1
}
{
println(2)
}
object O
val q = p + 1
fun a(p: kotlin.Int): kotlin.Int = b(p) + 1
trait T
}
class C {
fun aa(x: Int): Int = bb(x) + 1
fun bb(y: Int): Int = aa(y) - 1
{
println(1)
}
class X
inner class Y
trait T
object O
val p = 1
val q = p + 1
{
println(2)
}
class object {
fun f() = 1
val g = f() - 1
}
}
class D {
fun a(x: Int): Int = b(x) + 1
fun b(y: Int): Int = a(y) - 1
{
println(1)
}
class X
inner class Y
trait T
object O
val q = p + 1
val p = 1
{
println(2)
}
class object {
fun f() = 1
val g = f() - 1
}
}
class E {
fun a(x: Int): Int = b(x) + 1
fun b(y: Int): Int = a(y) - 1
{
println(1)
}
class XX
inner class Y
trait T
object O
val p = 1
val q = p + 1
{
println(2)
}
class object {
fun f() = 1
val g = f() - 1
}
}
}
@@ -0,0 +1,56 @@
class A {
fun a(x: Int): Int = b(x) + 1
fun b(y: Int): Int = a(y) - 1
{
println(1)
}
class X
inner class Y
trait T
object O
val p = 1
val q = p + 1
{
println(2)
}
class object {
fun f() = 1
val g = f() - 1
}
}
class B {
{
println(1)
}
class X
fun b(p: kotlin.Int): kotlin.Int = a(p) - 1
inner class Y
val p = 1
class object {
fun f() = 1
val g = f() - 1
}
{
println(2)
}
object O
val q = p + 1
fun a(p: kotlin.Int): kotlin.Int = b(p) + 1
trait T
}
@@ -0,0 +1,25 @@
fun foo() {
open class Z(p: Int)
trait T
trait U;
{
<selection>class A: Z(1), T, U</selection>
}
{
class B: Z(1), U, T
}
{
class C: Z(1)
}
{
class D: Z(1), T
}
{
class E: Z(1), U
}
}
@@ -0,0 +1,3 @@
class A: Z(1), T, U
class B: Z(1), U, T
@@ -0,0 +1,26 @@
// WITH_RUNTIME
fun foo(f: (Int) -> Unit) {
<selection>{ (n: Int, s: String) ->
val a = n + 1
println(s)
f(a)
}</selection>
{ (s: String, n: Int) ->
val a = n + 1
println(s)
f(a)
}
{ (m: Int, r: String) ->
val b = m + 1
println(r)
f(b)
}
val g: (Int, String) -> Unit = { (a, b) ->
val m = a + 1
println(b)
f(m)
}
}
@@ -0,0 +1,17 @@
{ (n: Int, s: String) ->
val a = n + 1
println(s)
f(a)
}
{ (m: Int, r: String) ->
val b = m + 1
println(r)
f(b)
}
{ (a, b) ->
val m = a + 1
println(b)
f(m)
}
@@ -0,0 +1,16 @@
fun foo(f: (Int) -> Unit) {
<selection>{
val a = 1
f(a)
}</selection>
{
val b = 1
f(b)
}
val g: () -> Unit = {
val c = 1
f(c)
}
}
@@ -0,0 +1,14 @@
{
val a = 1
f(a)
}
{
val b = 1
f(b)
}
{
val c = 1
f(c)
}
@@ -0,0 +1,32 @@
// WITH_RUNTIME
fun foo(f: (Int) -> Unit) {
{ (m: Int, n: Int, s: String) ->
val a = n + m
println(s)
f(a)
}
{ (n: Int, s: String) ->
val a = n + 1
println(s)
f(a)
}
<selection>{ Int.(n: Int, s: String) ->
val a = n + this
println(s)
f(a)
}</selection>
{ Int.(m: Int, r: String) ->
val b = m + this
println(r)
f(b)
}
val g: Int.(Int, String) -> Unit = { (a, b) ->
val m = a + this
println(b)
f(m)
}
}
@@ -0,0 +1,17 @@
{ Int.(n: Int, s: String) ->
val a = n + this
println(s)
f(a)
}
{ Int.(m: Int, r: String) ->
val b = m + this
println(r)
f(b)
}
{ (a, b) ->
val m = a + this
println(b)
f(m)
}
@@ -0,0 +1,21 @@
fun foo(f: (Int) -> Unit) {
<selection>{ (n: Int) ->
val a = n + 1
f(a)
}</selection>
val x: (Int) -> Unit = {
val a = it + 1
f(a)
}
{ (m: Int) ->
val b = m + 1
f(b)
}
val g: (Int) -> Unit = { a ->
val m = a + 1
f(m)
}
}
@@ -0,0 +1,19 @@
{ (n: Int) ->
val a = n + 1
f(a)
}
{
val a = it + 1
f(a)
}
{ (m: Int) ->
val b = m + 1
f(b)
}
{ a ->
val m = a + 1
f(m)
}
@@ -0,0 +1,16 @@
fun foo() {
val a: () -> Unit = <selection>{
val t = 1
t
}</selection>
{
val v = 1
v
}
val b = {
val u = 1
u
}
}
@@ -0,0 +1,14 @@
{
val t = 1
t
}
{
val v = 1
v
}
{
val u = 1
u
}
@@ -0,0 +1,24 @@
class A(val n: Int)
fun test() {
<selection>fun foo<T: A>(t: T): Int {
fun A.a(n: Int): Int = this.n + n
fun A.b(n: Int): Int = this.n - n
return t.n + A(1).a(2) - A(2).b(1)
}</selection>
fun foo<U: A>(u: U): Int {
fun A.x(m: Int): Int = n + m
fun A.y(n: Int): Int = this.n - n
return u.n + A(1).x(2) - A(2).y(1)
}
fun foo<V: A>(v: V): Int {
fun A.a(n: Int): Int = this.n + n
fun A.b(n: Int): Int = this.n + n
return v.n + A(1).a(2) - A(2).b(1)
}
}
@@ -0,0 +1,13 @@
fun foo<T: A>(t: T): Int {
fun A.a(n: Int): Int = this.n + n
fun A.b(n: Int): Int = this.n - n
return t.n + A(1).a(2) - A(2).b(1)
}
fun foo<U: A>(u: U): Int {
fun A.x(m: Int): Int = n + m
fun A.y(n: Int): Int = this.n - n
return u.n + A(1).x(2) - A(2).y(1)
}
@@ -0,0 +1,31 @@
class A(val n: Int)
fun test() {
<selection>fun foo<T: A>(t: T): Int {
fun a(p: Int): Int = p + 1
fun b(q: Int): Int = q - 1
return t.n + a(1) - b(2)
}</selection>
fun foo<U: A>(u: U): Int {
fun x(a: Int): Int = a + 1
fun y(a: Int): Int = a - 1
return u.n + x(1) - y(2)
}
fun foo<V: A>(v: V): Int {
fun a(p: Int): Int = p + 1
fun b(p: Int): Int = p + 1
return v.n + a(1) - b(2)
}
fun a(p: Int): Int = p + 1
fun b(q: Int): Int = q - 1
fun foo<W: A>(w: W): Int {
return w.n + a(1) - b(2)
}
}
@@ -0,0 +1,13 @@
fun foo<T: A>(t: T): Int {
fun a(p: Int): Int = p + 1
fun b(q: Int): Int = q - 1
return t.n + a(1) - b(2)
}
fun foo<U: A>(u: U): Int {
fun x(a: Int): Int = a + 1
fun y(a: Int): Int = a - 1
return u.n + x(1) - y(2)
}
@@ -0,0 +1,34 @@
fun foo1(): Int <selection>{
val a = 1
var b = 2
return a - b
}</selection>
fun foo2(): Int {
val x = 1
var y = 2
return x - y
}
fun foo3(): Int {
val x = 1
val y = 2
return x - y
}
fun foo4(): Int {
val a = 1
var b = 0
return a - b
}
val a = 1
var b = 2
fun foo5(): Int {
return a - b
}
@@ -0,0 +1,13 @@
{
val a = 1
var b = 2
return a - b
}
{
val x = 1
var y = 2
return x - y
}
@@ -0,0 +1,20 @@
data class A(val a: Int, val b: String)
fun foo1() {
<selection>val (a, b) = A(1, "2")</selection>
val (u, v) = A(2, "2")
val (x, y) = A(1, "2")
}
fun foo2() {
fun A.component1(): Int = a + 1
val (aa, bb) = A(1, "2")
val (uu, vv) = A(2, "2")
val (xx, yy) = A(1, "2")
}
fun foo3() {
val (u, v) = A(2, "2")
val (x, y) = A(1, "2")
}
@@ -0,0 +1,5 @@
val (a, b) = A(1, "2")
val (x, y) = A(1, "2")
val (x, y) = A(1, "2")
@@ -0,0 +1,17 @@
fun foo() {
trait T
<selection>fun bar1<A, B, C>(a: A, b: B, c: C): A where B: A, C: B, C: T = c</selection>
fun bar2<X, Y: X, Z>(x: X, y: Y, z: Z): X where Z: Y, Z: T = z
fun bar3<X, Y, Z: Y>(x: X, y: Y, z: Z): X where Y: X, Z: T = z
fun bar4<X, Y: X, Z: Y>(x: X, y: Y, z: Z): X where Z: T = z
fun bar5<X, Y: X, Z: T>(x: X, y: Y, z: Z): X where Z: Y = z
fun bar6<X, Z: Y, Y>(x: X, y: Y, z: Z): X where Y: X, Z: T = z
fun bar7<X, Y: T, Z>(x: X, y: Y, z: Z): X where Y: X, Z: Y, Z: T = z
}
@@ -0,0 +1,9 @@
fun bar1<A, B, C>(a: A, b: B, c: C): A where B: A, C: B, C: T = c
fun bar2<X, Y: X, Z>(x: X, y: Y, z: Z): X where Z: Y, Z: T = z
fun bar3<X, Y, Z: Y>(x: X, y: Y, z: Z): X where Y: X, Z: T = z
fun bar4<X, Y: X, Z: Y>(x: X, y: Y, z: Z): X where Z: T = z
fun bar5<X, Y: X, Z: T>(x: X, y: Y, z: Z): X where Z: Y = z
@@ -0,0 +1,5 @@
fun foo(a: Array<Int>) {
<selection>a[0]</selection>
a[1]
a[0] = a[0] + a[1]
}
@@ -0,0 +1,3 @@
a[0]
a[0]
@@ -0,0 +1,13 @@
// WITH_RUNTIME
class A {
inner class B
inner class C
fun foo() {
<selection>::B</selection>
::C
A::B
A::C
}
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
class A {
fun bar() {
}
fun baz() {
}
fun foo() {
<selection>::bar</selection>
::baz
A::bar
A::baz
}
}
@@ -0,0 +1,14 @@
class Bar {
{
Foo()()
}
}
class Foo() {
fun Bar.invoke() {}
}
fun foobar(f: Foo) {
<selection>Bar().f()</selection>
Bar().f()
}
@@ -0,0 +1,3 @@
Bar().f()
Bar().f()
@@ -0,0 +1,23 @@
// WITH_RUNTIME
fun Int.contains(n: Int): Boolean = n < this
fun foo(n: Int): Int {
if (n in 1) {
println(1)
}
when(n) {
<selection>in 1</selection> -> println(1)
in 2 -> println(2)
}
if (1.contains(n)) {
println(1)
}
when(n) {
in 1 -> println(1)
}
return 1
}
@@ -0,0 +1,3 @@
in 1
in 1
@@ -0,0 +1,9 @@
// DISABLE-ERRORS
fun bar(n: Int): Int = n + 1
fun foo() {
<selection>bar(1, 2)</selection>
bar(1)
bar(1, 2)
bar(2, 1)
}
@@ -0,0 +1,3 @@
bar(1, 2)
bar(1, 2)
@@ -0,0 +1,11 @@
class A {
fun bar() {
}
}
fun A.foo() {
<selection>bar()</selection>
this.bar()
this@foo.bar()
}
@@ -0,0 +1,5 @@
bar()
this.bar()
this@foo.bar()
@@ -0,0 +1,11 @@
class A {
fun bar() {
}
fun foo() {
<selection>bar()</selection>
this.bar()
this@A.bar()
}
}
@@ -0,0 +1,5 @@
bar()
this.bar()
this@A.bar()
@@ -0,0 +1,6 @@
fun Any.s(): String = toString()
fun foo() {
Any().s()
<selection>Any()?.s()</selection>
}
@@ -0,0 +1 @@
Any()?.s()
@@ -0,0 +1,7 @@
// DISABLE-ERRORS
fun foo() {
<selection>bar(1, 2)</selection>
bar(2, 1)
bar(1, 2)
bar(1)
}
@@ -0,0 +1,3 @@
bar(1, 2)
bar(1, 2)
@@ -0,0 +1,8 @@
fun bar(vararg n: Int) {}
fun foo() {
<selection>bar(1, 2, 3)</selection>
bar(1, 2)
bar(1, 2, 3)
bar(*IntArray(3))
}
@@ -0,0 +1,3 @@
bar(1, 2, 3)
bar(1, 2, 3)
@@ -0,0 +1,6 @@
fun foo(a: Any, b: Any) {
<selection>a as String</selection>
a is String
b as String
a as? String
}
@@ -0,0 +1 @@
a as String
@@ -0,0 +1,5 @@
fun foo(a: Any, b: Any) {
<selection>a is String</selection>
a as String
b is String
}
@@ -0,0 +1 @@
a is String
@@ -0,0 +1,6 @@
fun foo(a: Any, b: Any) {
<selection>a as? String</selection>
b as String
a is String
a as String
}
@@ -0,0 +1 @@
a as? String

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