mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-04 08:31:30 +00:00
Change Signature: Use new signature when looking for redeclaration conflicts
#KT-14583 Fixed
This commit is contained in:
@@ -224,6 +224,10 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
||||
|
||||
- [`KT-14569`](https://youtrack.jetbrains.com/issue/KT-14569) Convert Property to Function Intention: Search occurrences using progress dialog
|
||||
|
||||
#### Refactorings
|
||||
|
||||
- [`KT-14583`](https://youtrack.jetbrains.com/issue/KT-14583) Change Signature: Use new signature when looking for redeclaration conflicts
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### IDE
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions
|
||||
import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters
|
||||
import org.jetbrains.kotlin.idea.search.restrictToKotlinSources
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.buildProcessDelegationCallConstructorUsagesTask
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.processDelegationCallConstructorUsages
|
||||
import org.jetbrains.kotlin.idea.util.*
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
@@ -72,6 +71,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.util.*
|
||||
|
||||
class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
|
||||
@@ -535,13 +535,16 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
|
||||
callableScope.getAllAccessibleFunctions(newName)
|
||||
else
|
||||
callableScope.getAllAccessibleVariables(newName)
|
||||
val newTypes = info.newParameters.map { it.currentTypeInfo.type }
|
||||
for (conflict in conflicts) {
|
||||
if (conflict === oldDescriptor) continue
|
||||
|
||||
val conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict)
|
||||
if (conflictElement === info.method) continue
|
||||
|
||||
if (conflict.valueParameters.map { it.type } == oldDescriptor.valueParameters.map { it.type }) {
|
||||
val candidateTypes = conflict.extensionReceiverParameter?.type.singletonOrEmptyList() + conflict.valueParameters.map { it.type }
|
||||
|
||||
if (candidateTypes == newTypes) {
|
||||
result.putValue(conflictElement, "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'")
|
||||
break
|
||||
}
|
||||
|
||||
3
idea/testData/intentions/convertReceiverToParameter/validOverload.kt
vendored
Normal file
3
idea/testData/intentions/convertReceiverToParameter/validOverload.kt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fun conflict() {}
|
||||
class Convertable {}
|
||||
fun <caret>Convertable.conflict() {}
|
||||
3
idea/testData/intentions/convertReceiverToParameter/validOverload.kt.after
vendored
Normal file
3
idea/testData/intentions/convertReceiverToParameter/validOverload.kt.after
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fun conflict() {}
|
||||
class Convertable {}
|
||||
fun <caret>conflict(convertable: Convertable) {}
|
||||
@@ -4863,6 +4863,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/topLevelFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("validOverload.kt")
|
||||
public void testValidOverload() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertReceiverToParameter/validOverload.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/convertSealedClassToEnum")
|
||||
|
||||
Reference in New Issue
Block a user