No callable reference to generic callables
This commit is contained in:
@@ -48,7 +48,7 @@ public sealed class CallType<TReceiver : JetElement?>(val descriptorKindFilter:
|
|||||||
|
|
||||||
object UNARY : CallType<JetExpression>(DescriptorKindFilter.FUNCTIONS exclude NonUnaryExclude)
|
object UNARY : CallType<JetExpression>(DescriptorKindFilter.FUNCTIONS exclude NonUnaryExclude)
|
||||||
|
|
||||||
object CALLABLE_REFERENCE : CallType<JetTypeReference?>(DescriptorKindFilter.CALLABLES exclude LocalsAndSyntheticExclude/* currently not supported for locals and synthetic */)
|
object CALLABLE_REFERENCE : CallType<JetTypeReference?>(DescriptorKindFilter.CALLABLES exclude CallableReferenceExclude)
|
||||||
|
|
||||||
object IMPORT_DIRECTIVE : CallType<JetExpression?>(DescriptorKindFilter.ALL)
|
object IMPORT_DIRECTIVE : CallType<JetExpression?>(DescriptorKindFilter.ALL)
|
||||||
|
|
||||||
@@ -74,9 +74,9 @@ public sealed class CallType<TReceiver : JetElement?>(val descriptorKindFilter:
|
|||||||
get() = 0
|
get() = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private object LocalsAndSyntheticExclude : DescriptorKindExclude {
|
private object CallableReferenceExclude : DescriptorKindExclude {
|
||||||
override fun excludes(descriptor: DeclarationDescriptor)
|
override fun excludes(descriptor: DeclarationDescriptor) /* currently not supported for locals, synthetic and genetic */
|
||||||
= descriptor !is CallableMemberDescriptor || descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED
|
= descriptor !is CallableMemberDescriptor || descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED || descriptor.typeParameters.isNotEmpty()
|
||||||
|
|
||||||
override val fullyExcludedDescriptorKinds: Int
|
override val fullyExcludedDescriptorKinds: Int
|
||||||
get() = 0
|
get() = 0
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ private fun MutableCollection<LookupElement>.addLookupElementsForNullable(factor
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CallableDescriptor.callableReferenceType(resolutionFacade: ResolutionFacade): FuzzyType? {
|
fun CallableDescriptor.callableReferenceType(resolutionFacade: ResolutionFacade): FuzzyType? {
|
||||||
|
if (!CallType.CALLABLE_REFERENCE.descriptorKindFilter.accepts(this)) return null // not supported by callable references
|
||||||
val type = getReflectionTypeForCandidateDescriptor(this, resolutionFacade.getFrontendService(ReflectionTypes::class.java)) ?: return null
|
val type = getReflectionTypeForCandidateDescriptor(this, resolutionFacade.getFrontendService(ReflectionTypes::class.java)) ?: return null
|
||||||
//TODO: no generic
|
return FuzzyType(type, emptyList())
|
||||||
return FuzzyType(type, emptyList()/* references to generic functions not supported yet */)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LookupElementFactory.createLookupElementsInSmartCompletion(
|
fun LookupElementFactory.createLookupElementsInSmartCompletion(
|
||||||
|
|||||||
+4
@@ -9,6 +9,9 @@ var globalVar = 1
|
|||||||
|
|
||||||
fun funWithFunctionParameter(p: () -> Unit) {}
|
fun funWithFunctionParameter(p: () -> Unit) {}
|
||||||
|
|
||||||
|
// callable references to generic functions are not supported currently
|
||||||
|
fun <T> genericFun(t: T): T = t
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
fun memberFun(){}
|
fun memberFun(){}
|
||||||
|
|
||||||
@@ -51,3 +54,4 @@ abstract class AbstractClass
|
|||||||
// ABSENT: class
|
// ABSENT: class
|
||||||
// ABSENT: class.java
|
// ABSENT: class.java
|
||||||
// EXIST: { itemText: "funWithFunctionParameter", tailText: "(p: () -> Unit) (<root>)", attributes: "" }
|
// EXIST: { itemText: "funWithFunctionParameter", tailText: "(p: () -> Unit) (<root>)", attributes: "" }
|
||||||
|
// ABSENT: genericFun
|
||||||
|
|||||||
@@ -7,4 +7,8 @@ fun bar() {
|
|||||||
fun f(){}
|
fun f(){}
|
||||||
fun f(i: Int){}
|
fun f(i: Int){}
|
||||||
|
|
||||||
|
// currently not supported for generic funcitons
|
||||||
|
fun<T> genericF(t: T){}
|
||||||
|
|
||||||
// EXIST: ::f
|
// EXIST: ::f
|
||||||
|
// ABSENT: ::genericF
|
||||||
|
|||||||
Reference in New Issue
Block a user