Convert Receiver to Parameter Intention: Update function descriptor after template is finished (otherwise some references may be processed incorrectly)
This commit is contained in:
committed by
Ilya Gorbunov
parent
51566942f6
commit
8c3fcf69f2
@@ -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
|
||||
|
||||
|
||||
+7
-1
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user