Change function signature: add/change receiver type
#KT-21799 Fixed
This commit is contained in:
committed by
klunnii
parent
9f3ce099ee
commit
f20a6b7fe1
@@ -338,8 +338,15 @@ class ChangeMemberFunctionSignatureFix private constructor(
|
|||||||
} as KtParameterList
|
} as KtParameterList
|
||||||
ShortenReferences.DEFAULT.process(newParameterList)
|
ShortenReferences.DEFAULT.process(newParameterList)
|
||||||
|
|
||||||
if (patternFunction.receiverTypeReference == null && function.receiverTypeReference != null) {
|
val patternFunctionReceiver = patternFunction.receiverTypeReference
|
||||||
function.setReceiverTypeReference(null)
|
if (patternFunctionReceiver == null) {
|
||||||
|
if (function.receiverTypeReference != null) {
|
||||||
|
function.setReceiverTypeReference(null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
function.setReceiverTypeReference(patternFunction.receiverTypeReference)?.let {
|
||||||
|
ShortenReferences.DEFAULT.process(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val patternTypeParameterList = patternFunction.typeParameterList
|
val patternTypeParameterList = patternFunction.typeParameterList
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// "Change function signature to 'fun Int.foo(a: String)'" "true"
|
||||||
|
abstract class C {
|
||||||
|
abstract fun Int.foo(a: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : C() {
|
||||||
|
<caret>override fun foo(a: Int) {}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "Change function signature to 'fun Int.foo(a: String)'" "true"
|
||||||
|
abstract class C {
|
||||||
|
abstract fun Int.foo(a: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : C() {
|
||||||
|
override fun Int.foo(a: String) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// "Change function signature to 'fun Int.foo(a: String)'" "true"
|
||||||
|
abstract class C {
|
||||||
|
abstract fun Int.foo(a: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : C() {
|
||||||
|
<caret>override fun String.foo(a: Int) {}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "Change function signature to 'fun Int.foo(a: String)'" "true"
|
||||||
|
abstract class C {
|
||||||
|
abstract fun Int.foo(a: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : C() {
|
||||||
|
override fun Int.foo(a: String) {}
|
||||||
|
}
|
||||||
@@ -10162,6 +10162,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionNonUnitReturnType.kt");
|
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionNonUnitReturnType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("addFunctionReciever.kt")
|
||||||
|
public void testAddFunctionReciever() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionReciever.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("addFunctionSealedClass.kt")
|
@TestMetadata("addFunctionSealedClass.kt")
|
||||||
public void testAddFunctionSealedClass() throws Exception {
|
public void testAddFunctionSealedClass() throws Exception {
|
||||||
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionSealedClass.kt");
|
runTest("idea/testData/quickfix/override/nothingToOverride/addFunctionSealedClass.kt");
|
||||||
@@ -10226,6 +10231,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/override/nothingToOverride"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/override/nothingToOverride"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("changeFunctionReciever.kt")
|
||||||
|
public void testChangeFunctionReciever() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/override/nothingToOverride/changeFunctionReciever.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("changeParameterType.kt")
|
@TestMetadata("changeParameterType.kt")
|
||||||
public void testChangeParameterType() throws Exception {
|
public void testChangeParameterType() throws Exception {
|
||||||
runTest("idea/testData/quickfix/override/nothingToOverride/changeParameterType.kt");
|
runTest("idea/testData/quickfix/override/nothingToOverride/changeParameterType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user