KT-12100 convert try / finally to use: 'this' receiver is now left as is

This commit is contained in:
Mikhail Glukhikh
2016-12-01 17:23:25 +03:00
parent f513514c53
commit 0ac443066e
3 changed files with 6 additions and 2 deletions
@@ -51,6 +51,10 @@ class ConvertTryFinallyToUseCallIntention : SelfTargetingOffsetIndependentIntent
appendName(resourceName)
appendFixedText(".")
}
else if (finallyExpressionReceiver is KtThisExpression) {
appendFixedText(finallyExpressionReceiver.text)
appendFixedText(".")
}
appendFixedText("use {")
if (resourceName != null) {
@@ -3,5 +3,5 @@ import java.io.File
import java.io.BufferedReader
fun BufferedReader.foo() {
use { this.readLine() }
this.use { this.readLine() }
}
@@ -8,6 +8,6 @@ class MyCloseable : Closeable {
fun process(x: Int) = x
fun Int.foo() {
use { this@MyCloseable.process(this) }
this@MyCloseable.use { this@MyCloseable.process(this) }
}
}