Don't exclude callable references with type parameters from completion

This commit is contained in:
Mikhail Zarechenskiy
2017-01-25 19:38:56 +03:00
parent e04d18f3de
commit 462aed35d3
5 changed files with 24 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
import org.jetbrains.kotlin.psi.psiUtil.isImportDirectiveExpression
import org.jetbrains.kotlin.psi.psiUtil.isPackageDirectiveExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoBefore
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
@@ -89,8 +88,8 @@ sealed class CallType<TReceiver : KtElement?>(val descriptorKindFilter: Descript
}
private object CallableReferenceExclude : DescriptorKindExclude() {
override fun excludes(descriptor: DeclarationDescriptor) /* currently not supported for locals, synthetic and genetic */
= descriptor !is CallableMemberDescriptor || descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED || descriptor.typeParameters.isNotEmpty()
override fun excludes(descriptor: DeclarationDescriptor) /* currently not supported for locals and synthetic */
= descriptor !is CallableMemberDescriptor || descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED
override val fullyExcludedDescriptorKinds: Int
get() = 0
@@ -9,7 +9,6 @@ var globalVar = 1
fun funWithFunctionParameter(p: () -> Unit) {}
// callable references to generic functions are not supported currently
fun <T> genericFun(t: T): T = t
class C {
@@ -54,7 +53,7 @@ abstract class AbstractClass
// ABSENT: class
// ABSENT: class.java
// EXIST: { itemText: "funWithFunctionParameter", tailText: "(p: () -> Unit) (<root>)", attributes: "" }
// ABSENT: genericFun
// EXIST: { itemText: "genericFun", tailText: "(t: T) (<root>)", attributes: "" }
// ABSENT: "kotlin"
// ABSENT: "java"
@@ -0,0 +1,8 @@
class Wrapper<T>(val value: T)
fun test() {
listOf<String>().map(::Wrap<caret>)
}
// EXIST: { lookupString: "Wrapper", itemText: "Wrapper", tailText: "(value: T)", attributes: "" }
// NOTHING_ELSE
@@ -1261,6 +1261,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
doTest(fileName);
}
@TestMetadata("GenericConstructor.kt")
public void testGenericConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/callableReference/GenericConstructor.kt");
doTest(fileName);
}
@TestMetadata("HigherOrderFunction.kt")
public void testHigherOrderFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/callableReference/HigherOrderFunction.kt");
@@ -1261,6 +1261,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
doTest(fileName);
}
@TestMetadata("GenericConstructor.kt")
public void testGenericConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/callableReference/GenericConstructor.kt");
doTest(fileName);
}
@TestMetadata("HigherOrderFunction.kt")
public void testHigherOrderFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/callableReference/HigherOrderFunction.kt");