Extraction Engine: Do not wrap companion member references inside of the with call if it's disabled in extraction options

#KT-13781 Fixed
This commit is contained in:
Alexey Sedunov
2016-11-24 16:07:13 +03:00
parent 61210d6ba2
commit 25cebbab4b
5 changed files with 39 additions and 1 deletions
+1
View File
@@ -346,6 +346,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
- [`KT-14596`](https://youtrack.jetbrains.com/issue/KT-14596) Safe Delete: Fix exception on deleting Java class used in Kotlin import directive(s)
- [`KT-14325`](https://youtrack.jetbrains.com/issue/KT-14325) Rename: Fix exceptions on moving file with facade class to another package
- [`KT-14197`](https://youtrack.jetbrains.com/issue/KT-14197) Move: Fix callable reference processing when moving to another package
- [`KT-13781`](https://youtrack.jetbrains.com/issue/KT-13781) Extract Function: Do not wrap companion member references inside of the `with` call
## 1.0.5
@@ -97,7 +97,8 @@ internal fun ExtractionData.inferParametersInfo(
val twoReceivers = resolvedCall != null && resolvedCall.hasBothReceivers()
val dispatchReceiverDescriptor = (resolvedCall?.dispatchReceiver as? ImplicitReceiver)?.declarationDescriptor
if (twoReceivers
if (options.canWrapInWith
&& twoReceivers
&& resolvedCall!!.extensionReceiver is ExpressionReceiver
&& DescriptorUtils.isObject(dispatchReceiverDescriptor)) {
info.replacementMap.putValue(refInfo.resolveResult.originalRefExpr,
@@ -0,0 +1,13 @@
// PARAM_DESCRIPTOR: value-parameter s: kotlin.String defined in Outer.O.f
// PARAM_TYPES: kotlin.String
class Outer {
object O {
fun f(s: String) {
<selection>s.funFromCompanion()</selection>
}
}
companion object {
fun String.funFromCompanion(): String = ""
}
}
@@ -0,0 +1,17 @@
// PARAM_DESCRIPTOR: value-parameter s: kotlin.String defined in Outer.O.f
// PARAM_TYPES: kotlin.String
class Outer {
object O {
fun f(s: String) {
__dummyTestFun__(s)
}
private fun __dummyTestFun__(s: String) {
s.funFromCompanion()
}
}
companion object {
fun String.funFromCompanion(): String = ""
}
}
@@ -874,6 +874,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
doExtractFunctionTest(fileName);
}
@TestMetadata("companionObjectMemberRef.kt")
public void testCompanionObjectMemberRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/companionObjectMemberRef.kt");
doExtractFunctionTest(fileName);
}
@TestMetadata("convertBinaryExpression.kt")
public void testConvertBinaryExpression() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/convertBinaryExpression.kt");