Do not auto-import convention methods without 'operator' modifier (KT-10212)

#KT-10212 Fixed
This commit is contained in:
Nikolay Krasko
2016-01-19 20:26:55 +03:00
parent 84d507b770
commit 10648f44ac
4 changed files with 28 additions and 18 deletions
@@ -62,7 +62,7 @@ sealed class CallType<TReceiver : KtElement?>(val descriptorKindFilter: Descript
object TYPE : CallType<KtExpression?>(DescriptorKindFilter(DescriptorKindFilter.CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK) exclude DescriptorKindExclude.EnumEntry)
object DELEGATE : CallType<KtExpression?>(DescriptorKindFilter.FUNCTIONS)
object DELEGATE : CallType<KtExpression?>(DescriptorKindFilter.FUNCTIONS exclude NonOperatorExclude)
object ANNOTATION : CallType<KtExpression?>(DescriptorKindFilter(DescriptorKindFilter.CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK) exclude NonAnnotationClassifierExclude)
@@ -0,0 +1,20 @@
// FILE: first.before.kt
// "Import" "false"
// ERROR: Missing 'getValue(kotlin.Nothing?, kotlin.reflect.KProperty<*>)' method on delegate of type 'kotlin.String'
package b
val x: String by "<caret>" // <--- should not propose to auto-import a.getValue,
// because that would not fix the error
// FILE: second.kt
package a
import kotlin.reflect.KProperty
fun String.getValue(x: Any?, y: KProperty<*>) = ""
// FILE: first.after.kt
// Should not be checked
@@ -29,20 +29,4 @@ fun Some.get(s: String) {}
// FILE: first.after.kt
// "Import" "true"
// ERROR: Unresolved reference: foo()["str"]
// ERROR: No get method providing array access
package testing
import some.Some
import some.get
fun foo(): Some = Some()
fun testing() {
foo()<caret>["str"]
}
// Should not be checked
@@ -101,6 +101,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
doTestWithExtraFile(fileName);
}
@TestMetadata("delegateNoOperator.test")
public void testDelegateNoOperator() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/delegateNoOperator.test");
doTestWithExtraFile(fileName);
}
@TestMetadata("divOperator.before.Main.kt")
public void testDivOperator() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/divOperator.before.Main.kt");