Convert parameter <-> receiver intention: do not add label to 'this' if not needed
#KT-17615 Fixed #KT-30028 Fixed #KT-32809 Fixed #KT-28085 Fixed #KT-37508 Fixed Convert receiver to parameter: #KT-37508 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
34e9e899f8
commit
c344b85d4e
@@ -0,0 +1,8 @@
|
||||
class A
|
||||
|
||||
class B {
|
||||
val foo = 1
|
||||
fun test(<caret>a: A) {
|
||||
this.foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A
|
||||
|
||||
class B {
|
||||
val foo = 1
|
||||
fun A.test() {
|
||||
this@B.foo
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(<caret>p: Any) {
|
||||
object : Runnable {
|
||||
override fun run() {
|
||||
print(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun Any.foo() {
|
||||
object : Runnable {
|
||||
override fun run() {
|
||||
print(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
class C(val x: Int, val y: Int, var z: Int)
|
||||
|
||||
class CBuilder {
|
||||
var x: Int = 0
|
||||
var y: Int = 0
|
||||
fun build() = C(x, y, 0)
|
||||
}
|
||||
|
||||
fun test(<caret>a: C) =
|
||||
CBuilder().apply {
|
||||
x = a.x
|
||||
y = a.y
|
||||
}.build().apply {
|
||||
val b = this
|
||||
z = b.x + b.y
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
class C(val x: Int, val y: Int, var z: Int)
|
||||
|
||||
class CBuilder {
|
||||
var x: Int = 0
|
||||
var y: Int = 0
|
||||
fun build() = C(x, y, 0)
|
||||
}
|
||||
|
||||
fun C.test() =
|
||||
CBuilder().apply {
|
||||
x = this@test.x
|
||||
y = this@test.y
|
||||
}.build().apply {
|
||||
val b = this
|
||||
z = b.x + b.y
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
interface I
|
||||
interface J
|
||||
|
||||
fun foo(<caret>a: Any, b: String) {
|
||||
b.bar {
|
||||
this as J
|
||||
}
|
||||
}
|
||||
|
||||
fun String.bar(init: I.() -> Unit) {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
interface I
|
||||
interface J
|
||||
|
||||
fun Any.foo(b: String) {
|
||||
b.bar {
|
||||
this as J
|
||||
}
|
||||
}
|
||||
|
||||
fun String.bar(init: I.() -> Unit) {}
|
||||
Reference in New Issue
Block a user