Create from Usages: Do not suggest on type-mismatched expressions which are not call arguments

#KT-14143 Fixed
This commit is contained in:
Alexey Sedunov
2016-10-04 16:23:36 +03:00
parent e4dc2ae367
commit da1178fe0c
4 changed files with 19 additions and 3 deletions
+1
View File
@@ -211,6 +211,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
- [`KT-13933`](https://youtrack.jetbrains.com/issue/KT-13933) Convert Parameter to Receiver: Do not qualify companion members with labeled 'this'
- [`KT-13942`](https://youtrack.jetbrains.com/issue/KT-13942) Redundant 'toString()' in String Template: Disable for qualified expressions with 'super' receiver
- [`KT-13878`](https://youtrack.jetbrains.com/issue/KT-13878) Remove Redundant Receiver Parameter: Fix exception receiver removal
- [`KT-14143`](https://youtrack.jetbrains.com/issue/KT-14143) Create from Usages: Do not suggest on type-mismatched expressions which are not call arguments
##### New features
@@ -75,9 +75,7 @@ sealed class CreateCallableFromCallActionFactory<E : KtExpression>(
Errors.TOO_MANY_ARGUMENTS,
Errors.NONE_APPLICABLE -> diagElement.getNonStrictParentOfType<KtCallExpression>()
Errors.TYPE_MISMATCH -> diagElement
.getParentOfTypeAndBranch<KtValueArgument> { getArgumentExpression() }
?.getStrictParentOfType<KtCallExpression>()
Errors.TYPE_MISMATCH -> (diagElement.parent as? KtValueArgument)?.getStrictParentOfType<KtCallExpression>()
else -> throw AssertionError("Unexpected diagnostic: ${diagnostic.factory}")
} as? KtExpression
@@ -0,0 +1,11 @@
// "Create function 'synchronized'" "false"
// ACTION: Convert expression to 'Int'
// ERROR: Type mismatch: inferred type is Float but Int was expected
// WITH_RUNTIME
fun test() {
var value = 0
synchronized(value) {
value = <caret>10 / 1f
}
}
@@ -2277,6 +2277,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("notExactArgument.kt")
public void testNotExactArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/notExactArgument.kt");
doTest(fileName);
}
@TestMetadata("objectMemberFunNoReceiver.kt")
public void testObjectMemberFunNoReceiver() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/objectMemberFunNoReceiver.kt");