Convert Receiver to Parameter Intention: Update function descriptor after template is finished (otherwise some references may be processed incorrectly)

This commit is contained in:
Alexey Sedunov
2016-10-14 19:20:57 +03:00
committed by Ilya Gorbunov
parent 51566942f6
commit 8c3fcf69f2
5 changed files with 22 additions and 1 deletions
+1
View File
@@ -253,6 +253,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
- [`KT-14143`](https://youtrack.jetbrains.com/issue/KT-14143) Create from Usages: Do not suggest on type-mismatched expressions which are not call arguments
- [`KT-13882`](https://youtrack.jetbrains.com/issue/KT-13882) Convert Receiver to Parameter: Fix AssertionError
- [`KT-14199`](https://youtrack.jetbrains.com/issue/KT-14199) Add Library: Fix exception due to resolution being run in the "dumb mode"
- Convert Receiver to Parameter: Fix this replacement
##### New features
@@ -100,7 +100,13 @@ class ConvertReceiverToParameterIntention : SelfTargetingOffsetIndependentIntent
val newName = addedParameter.name
revertChanges()
if (!brokenOff) {
runChangeSignature(element.project, descriptor, configureChangeSignature(newName), function.receiverTypeReference!!, text)
runChangeSignature(
element.project,
function.resolveToDescriptor() as FunctionDescriptor,
configureChangeSignature(newName),
function.receiverTypeReference!!,
text
)
}
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
class A(val s: String) {}
fun <caret>A.extend() = println(this.s)
@@ -0,0 +1,4 @@
// WITH_RUNTIME
class A(val s: String) {}
fun <caret>extend(a: A) = println(a.s)
@@ -4756,6 +4756,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("replaceThis.kt")
public void testReplaceThis() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/replaceThis.kt");
doTest(fileName);
}
@TestMetadata("topLevelFun.kt")
public void testTopLevelFun() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/topLevelFun.kt");