Checking "infix" modifier in completion and import popup

This commit is contained in:
Valentin Kipyatkov
2015-10-09 18:22:44 +03:00
parent a7577ac722
commit ee7425c1de
16 changed files with 49 additions and 24 deletions
@@ -57,9 +57,8 @@ public sealed class CallType<TReceiver : JetElement?>(val descriptorKindFilter:
object TYPE : CallType<JetExpression?>(DescriptorKindFilter(DescriptorKindFilter.CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK))
private object NonInfixExclude : DescriptorKindExclude() {
//TODO: check 'infix' modifier
override fun excludes(descriptor: DeclarationDescriptor) =
!(descriptor is SimpleFunctionDescriptor && descriptor.valueParameters.size() == 1)
!(descriptor is SimpleFunctionDescriptor && descriptor.isInfix)
override val fullyExcludedDescriptorKinds: Int
get() = 0
@@ -1,4 +1,4 @@
fun Int.func(s: String): Int{}
infix fun Int.func(s: String): Int{}
fun test() {
val floor = "Floor"
+6 -6
View File
@@ -1,18 +1,18 @@
class C {
fun foo(){}
fun bar(p: Int) {}
fun foo(p: Int){}
infix fun bar(p: Int) {}
fun zoo(p1: Int, p2: Int){}
val prop: Int = 1
}
fun C.xxx() {}
fun C.yyy(p: Int) {}
fun C.xxx(p: Int) {}
infix fun C.yyy(p: Int) {}
fun C.zzz(p1: Int, p2: Int) {}
val C.extensionProp: Int get() = 1
fun <A, B> A.and(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.and(that: B): Pair<A, B> = Pair(this, that)
fun String.ttt(p: Int) {}
infix fun String.ttt(p: Int) {}
fun f() {
C() <caret>
@@ -1,6 +1,6 @@
// checks that no special item "ext1 { String, Int -> ... }" created for infix call
fun Int.ext1(handler: (String, Int) -> Unit){}
fun Int.ext2(c: Char){}
infix fun Int.ext1(handler: (String, Int) -> Unit){}
infix fun Int.ext2(c: Char){}
fun foo() {
val pair = 1 ext<caret>
@@ -2,4 +2,4 @@ package dependency
class MyPair<A, B>(public val first: A, public val second: B)
public fun <A, B> A.pair(that: B): MyPair<A, B> = MyPair(this, that)
infix fun <A, B> A.pair(that: B): MyPair<A, B> = MyPair(this, that)
@@ -2,8 +2,8 @@ package other
import pack.C
fun C.xxx() {}
fun C.yyy(p: Int) {}
fun C.xxx(p: Int) {}
infix fun C.yyy(p: Int) {}
fun C.zzz(p1: Int, p2: Int) {}
val C.extensionProp: Int get() = 1
+1 -1
View File
@@ -1,4 +1,4 @@
fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
fun foo() {
val pair = 1 to<caret>
+1 -1
View File
@@ -1,4 +1,4 @@
fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
fun foo() {
val pair = 1 to <caret>
+1 -1
View File
@@ -1,4 +1,4 @@
fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
fun foo() {
val pair = 1 to<caret>
@@ -1,4 +1,4 @@
fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
fun foo() {
val pair = 1 to <caret>
@@ -1,3 +1,3 @@
package other
fun <A, B> A.makePair(that: B): Pair<A, B> = Pair(this, that)
infix fun <A, B> A.makePair(that: B): Pair<A, B> = Pair(this, that)
+4 -4
View File
@@ -1,11 +1,11 @@
class X {
fun foo(i: Int) = ""
fun bar() = ""
infix fun foo(i: Int) = ""
fun bar(i: Int) = ""
val prop: String = ""
}
fun X.ext1(s: String) = ""
fun X.ext2() = ""
infix fun X.ext1(s: String) = ""
fun X.ext2(p: Int) = ""
fun X.extProp: String get() = ""
val s: String = X() <caret>
@@ -1,3 +1,3 @@
package util
fun h.H.foo(other: h.H) = ""
infix fun h.H.foo(other: h.H) = ""
@@ -0,0 +1,3 @@
package util
fun h.H.foo(other: h.H) = ""
@@ -0,0 +1,17 @@
// "Import" "false"
// ERROR: Unresolved reference: foo
// ACTION: Create extension function 'foo'
// ACTION: Create extension property 'foo'
// ACTION: Create local variable 'foo'
// ACTION: Create member function 'foo'
// ACTION: Create member property 'foo'
// ACTION: Create parameter 'foo'
// ACTION: Replace infix call with ordinary call
package h
interface H
fun f(h: H) {
h <caret>foo h
}
@@ -149,6 +149,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
doTestWithExtraFile(fileName);
}
@TestMetadata("infixCall2.before.Main.kt")
public void testInfixCall2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/infixCall2.before.Main.kt");
doTestWithExtraFile(fileName);
}
@TestMetadata("minusOperator.before.Main.kt")
public void testMinusOperator() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/minusOperator.before.Main.kt");