@@ -2909,6 +2909,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2909
2909
if (HaveLParen)
2910
2910
return ;
2911
2911
2912
+ LLVM_FALLTHROUGH;
2913
+
2914
+ case LookupKind::ValueInDeclContext:
2915
+ case LookupKind::ImportFromModule:
2912
2916
if (auto *VD = dyn_cast<VarDecl>(D)) {
2913
2917
addVarDeclRef (VD, Reason);
2914
2918
return ;
@@ -2943,7 +2947,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2943
2947
2944
2948
if (auto *TAD = dyn_cast<TypeAliasDecl>(D)) {
2945
2949
addTypeAliasRef (TAD, Reason);
2946
- auto type = TAD->mapTypeIntoContext (TAD->getUnderlyingTypeLoc (). getType ());
2950
+ auto type = TAD->mapTypeIntoContext (TAD->getDeclaredInterfaceType ());
2947
2951
if (type->mayHaveMembers ())
2948
2952
addConstructorCallsForType (type, TAD->getName (), Reason);
2949
2953
return ;
@@ -2964,73 +2968,17 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2964
2968
2965
2969
if (auto *EED = dyn_cast<EnumElementDecl>(D)) {
2966
2970
addEnumElementRef (EED, Reason, /* HasTypeContext=*/ false );
2971
+ return ;
2967
2972
}
2968
2973
2969
2974
// Swift key path allows .[0]
2970
2975
if (shouldAddSubscriptCall ()) {
2971
2976
if (auto *SD = dyn_cast<SubscriptDecl>(D)) {
2972
- if (ExprType->is <AnyMetatypeType>())
2973
- return ;
2974
- addSubscriptCall (SD, Reason);
2975
- }
2976
- }
2977
- return ;
2978
-
2979
- case LookupKind::ValueInDeclContext:
2980
- case LookupKind::ImportFromModule:
2981
- if (auto *VD = dyn_cast<VarDecl>(D)) {
2982
- addVarDeclRef (VD, Reason);
2983
- return ;
2984
- }
2985
-
2986
- if (auto *FD = dyn_cast<FuncDecl>(D)) {
2987
- // We cannot call operators with a postfix parenthesis syntax.
2988
- if (FD->isBinaryOperator () || FD->isUnaryOperator ())
2989
- return ;
2990
-
2991
- // We cannot call accessors. We use VarDecls and SubscriptDecls to
2992
- // produce completions that refer to getters and setters.
2993
- if (isa<AccessorDecl>(FD))
2994
- return ;
2995
-
2996
- // Do we want compound function names here?
2997
- if (shouldUseFunctionReference (FD)) {
2998
- addCompoundFunctionName (FD, Reason);
2977
+ if (ExprType && !ExprType->is <AnyMetatypeType>())
2978
+ addSubscriptCall (SD, Reason);
2999
2979
return ;
3000
2980
}
3001
-
3002
- addMethodCall (FD, Reason);
3003
- return ;
3004
- }
3005
-
3006
- if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
3007
- addNominalTypeRef (NTD, Reason);
3008
- addConstructorCallsForType (NTD->getDeclaredInterfaceType (),
3009
- NTD->getName (), Reason);
3010
- return ;
3011
2981
}
3012
-
3013
- if (auto *TAD = dyn_cast<TypeAliasDecl>(D)) {
3014
- addTypeAliasRef (TAD, Reason);
3015
- auto type = TAD->mapTypeIntoContext (TAD->getDeclaredInterfaceType ());
3016
- if (type->mayHaveMembers ())
3017
- addConstructorCallsForType (type, TAD->getName (), Reason);
3018
- return ;
3019
- }
3020
-
3021
- if (auto *GP = dyn_cast<GenericTypeParamDecl>(D)) {
3022
- addGenericTypeParamRef (GP, Reason);
3023
- for (auto *protocol : GP->getConformingProtocols ())
3024
- addConstructorCallsForType (protocol->getDeclaredInterfaceType (),
3025
- GP->getName (), Reason);
3026
- return ;
3027
- }
3028
-
3029
- if (auto *AT = dyn_cast<AssociatedTypeDecl>(D)) {
3030
- addAssociatedTypeRef (AT, Reason);
3031
- return ;
3032
- }
3033
-
3034
2982
return ;
3035
2983
3036
2984
case LookupKind::EnumElement:
0 commit comments