Change Signature: Substitute parameter references in default values of call expression arguments

This commit is contained in:
Alexey Sedunov
2015-04-24 20:45:57 +03:00
parent cbbeec3790
commit 14f63cdce5
24 changed files with 549 additions and 24 deletions
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int): Int {
val b = 1
return (<selection>a + b</selection>) * 2
}
fun test() {
foo(1)
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(i: Int): Int {
val b = 1
return i * 2
}
fun test() {
foo(1 + b)
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int, b: Int): Int {
return <selection>a * b</selection> / 2
}
fun test() {
foo(1 + 2, 3 - 4)
}
@@ -0,0 +1,9 @@
// WITH_DEFAULT_VALUE: false
fun foo(i: Int): Int {
return i / 2
}
fun test() {
foo((1 + 2) * (3 - 4))
}
@@ -0,0 +1,18 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun A.foo(): Int {
return (<selection>this@A.a + a</selection>) / 2
}
fun test() {
A(1).foo()
}
}
fun test() {
val t = with(A(1)) {
A(2).foo()
}
}
@@ -0,0 +1,18 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun A.foo(i: Int): Int {
return i / 2
}
fun test() {
A(1).foo(a + A(1).a)
}
}
fun test() {
val t = with(A(1)) {
A(2).foo(a + A(2).a)
}
}
@@ -0,0 +1,16 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun foo(x: A): Int {
return (<selection>this.a + x.a</selection>) / 2
}
}
fun test() {
A(1).foo(A(2))
with(A(1)) {
foo(A(2))
this.foo(A(2))
}
}
@@ -0,0 +1,16 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun foo(i: Int): Int {
return i / 2
}
}
fun test() {
A(1).foo(A(1).a + A(2).a)
with(A(1)) {
foo(a + A(2).a)
this.foo(a + A(2).a)
}
}
@@ -0,0 +1,16 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun foo(x: A): Int {
return (<selection>a + x.a</selection>) / 2
}
}
fun test() {
A(1).foo(A(2))
with(A(1)) {
foo(A(2))
this.foo(A(2))
}
}
@@ -0,0 +1,16 @@
// WITH_DEFAULT_VALUE: false
public inline fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
class A(val a: Int) {
fun foo(i: Int): Int {
return i / 2
}
}
fun test() {
A(1).foo(A(1).a + A(2).a)
with(A(1)) {
foo(a + A(2).a)
this.foo(a + A(2).a)
}
}
@@ -0,0 +1,19 @@
// WITH_DEFAULT_VALUE: false
// TARGET:
open class A(val a: Int) {
constructor(): this(1)
fun foo(): Int {
return (<selection>a + 1</selection>) / 2
}
}
class B: A(1) {
}
class C: A {
constructor(n: Int): super(n + 1)
}
fun test() = A(1)
@@ -0,0 +1,19 @@
// WITH_DEFAULT_VALUE: false
// TARGET:
open class A(val a: Int, val i: Int) {
constructor(): this(1, 1 + 1)
fun foo(): Int {
return i / 2
}
}
class B: A(1, 1 + 1) {
}
class C: A {
constructor(n: Int): super(n + 1, n + 1 + 1)
}
fun test() = A(1, 1 + 1)
@@ -0,0 +1,18 @@
// WITH_DEFAULT_VALUE: false
open class A {
constructor(): this(1)
constructor(a: Int) {
val t = (<selection>a + 1</selection>) / 2
}
}
class B: A {
constructor(n: Int): super(n + 1)
}
class C: A(1) {
}
fun test() = A(1)
@@ -0,0 +1,18 @@
// WITH_DEFAULT_VALUE: false
open class A {
constructor(): this(1 + 1)
constructor(i: Int) {
val t = i / 2
}
}
class B: A {
constructor(n: Int): super(n + 1 + 1)
}
class C: A(1 + 1) {
}
fun test() = A(1 + 1)
@@ -0,0 +1,10 @@
// WITH_DEFAULT_VALUE: false
fun foo(a: Int): Int {
fun Int.bar(n: Int) = this + n
return (<selection>a bar 1</selection>) * 2
}
fun test() {
foo(2)
}
@@ -0,0 +1,10 @@
// WITH_DEFAULT_VALUE: false
fun foo(i: Int): Int {
fun Int.bar(n: Int) = this + n
return i * 2
}
fun test() {
foo(2 bar 1)
}
@@ -5,5 +5,5 @@ fun foo(a: Int, i: Int): Int {
}
fun test() {
foo(1, a + 1)
foo(1, 1 + 1)
}
@@ -5,5 +5,5 @@ fun foo(i: Int): Int {
}
fun test() {
foo(a + 1)
foo(1 + 1)
}
@@ -0,0 +1,10 @@
// WITH_DEFAULT_VALUE: false
fun foo(vararg a: Int): Int {
return (<selection>a.size() + 1</selection>) * 2
}
fun test() {
foo()
foo(1)
foo(1, 2)
}
@@ -0,0 +1,10 @@
// WITH_DEFAULT_VALUE: false
fun foo(i: Int): Int {
return i * 2
}
fun test() {
foo(a.size() + 1)
foo(a.size() + 1)
foo(a.size() + 1)
}