Extract Function: Skip callable reference selectors
#KT-13218 Fixed
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
###### Issues fixed
|
||||
- [`KT-13383`](https://youtrack.jetbrains.com/issue/KT-13383), [`KT-13379`](https://youtrack.jetbrains.com/issue/KT-13379) Override/Implement Members: Do not make return type non-nullable if base return type is explicitly nullable
|
||||
- [`KT-13244`](https://youtrack.jetbrains.com/issue/KT-13244) Override/Implement Members: Do not expand type aliases in the generated members
|
||||
- [`KT-13218`](https://youtrack.jetbrains.com/issue/KT-13218) Extract Function: Fix AssertionError on callable references
|
||||
|
||||
## 1.1-M01 (EAP-1)
|
||||
|
||||
|
||||
+1
@@ -220,6 +220,7 @@ data class ExtractionData(
|
||||
if (shouldSkipPrimaryReceiver && !(originalResolveResult.resolvedCall?.hasBothReceivers() ?: false)) continue
|
||||
}
|
||||
else {
|
||||
if (newRef.getParentOfTypeAndBranch<KtCallableReferenceExpression> { callableReference } != null) continue
|
||||
smartCast = originalContext[BindingContext.SMARTCAST, originalResolveResult.originalRefExpr]
|
||||
possibleTypes = getPossibleTypes(originalResolveResult.originalRefExpr, originalResolveResult.resolvedCall, originalContext)
|
||||
shouldSkipPrimaryReceiver = false
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// PARAM_DESCRIPTOR: value-parameter arg: kotlin.String defined in Foo.Companion.bar
|
||||
// PARAM_TYPES: kotlin.String
|
||||
|
||||
class Foo {
|
||||
var arguments: Map<String, String>? = null
|
||||
|
||||
companion object {
|
||||
fun bar(arg: String) = Foo().apply {
|
||||
arguments = <selection>mapOf(Foo::arguments.name to arg)</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// PARAM_DESCRIPTOR: value-parameter arg: kotlin.String defined in Foo.Companion.bar
|
||||
// PARAM_TYPES: kotlin.String
|
||||
|
||||
class Foo {
|
||||
var arguments: Map<String, String>? = null
|
||||
|
||||
companion object {
|
||||
fun bar(arg: String) = Foo().apply {
|
||||
arguments = map(arg)
|
||||
}
|
||||
|
||||
private fun map(arg: String) = mapOf(Foo::arguments.name to arg)
|
||||
}
|
||||
}
|
||||
+6
@@ -831,6 +831,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferenceSelector.kt")
|
||||
public void testCallableReferenceSelector() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/callableReferenceSelector.kt");
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("calleeExpression.kt")
|
||||
public void testCalleeExpression() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/calleeExpression.kt");
|
||||
|
||||
Reference in New Issue
Block a user