KT-12100 convert try / finally to use: 'this' receiver is now left as is
This commit is contained in:
@@ -51,6 +51,10 @@ class ConvertTryFinallyToUseCallIntention : SelfTargetingOffsetIndependentIntent
|
|||||||
appendName(resourceName)
|
appendName(resourceName)
|
||||||
appendFixedText(".")
|
appendFixedText(".")
|
||||||
}
|
}
|
||||||
|
else if (finallyExpressionReceiver is KtThisExpression) {
|
||||||
|
appendFixedText(finallyExpressionReceiver.text)
|
||||||
|
appendFixedText(".")
|
||||||
|
}
|
||||||
appendFixedText("use {")
|
appendFixedText("use {")
|
||||||
|
|
||||||
if (resourceName != null) {
|
if (resourceName != null) {
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ import java.io.File
|
|||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
|
||||||
fun BufferedReader.foo() {
|
fun BufferedReader.foo() {
|
||||||
use { this.readLine() }
|
this.use { this.readLine() }
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,6 @@ class MyCloseable : Closeable {
|
|||||||
fun process(x: Int) = x
|
fun process(x: Int) = x
|
||||||
|
|
||||||
fun Int.foo() {
|
fun Int.foo() {
|
||||||
use { this@MyCloseable.process(this) }
|
this@MyCloseable.use { this@MyCloseable.process(this) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user