@@ -2621,6 +2621,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2621
2621
(EED->hasAccessibility () && !EED->isAccessibleFrom (CurrDeclContext)) ||
2622
2622
shouldHideDeclFromCompletionResults (EED))
2623
2623
return ;
2624
+
2624
2625
CommandWordsPairs Pairs;
2625
2626
CodeCompletionResultBuilder Builder (
2626
2627
Sink,
@@ -2633,14 +2634,18 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2633
2634
Builder.addTextChunk (EED->getName ().str ());
2634
2635
if (EED->hasArgumentType ())
2635
2636
addPatternFromType (Builder, EED->getArgumentType ());
2636
- Type EnumType = EED->getType ();
2637
2637
2638
2638
// Enum element is of function type such as EnumName.type -> Int ->
2639
2639
// EnumName; however we should show Int -> EnumName as the type
2640
- if (auto FuncType = EED->getType ()->getAs <AnyFunctionType>()) {
2641
- EnumType = FuncType->getResult ();
2640
+ Type EnumType;
2641
+ if (EED->hasType ()) {
2642
+ EnumType = EED->getType ();
2643
+ if (auto FuncType = EnumType->getAs <AnyFunctionType>()) {
2644
+ EnumType = FuncType->getResult ();
2645
+ }
2642
2646
}
2643
- addTypeAnnotation (Builder, EnumType);
2647
+ if (EnumType)
2648
+ addTypeAnnotation (Builder, EnumType);
2644
2649
}
2645
2650
2646
2651
void addKeyword (StringRef Name, Type TypeAnnotation,
@@ -2936,14 +2941,19 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2936
2941
}
2937
2942
}
2938
2943
2939
- bool handleEnumElement (Decl *D, DeclVisibilityKind Reason) {
2944
+ bool handleEnumElement (ValueDecl *D, DeclVisibilityKind Reason) {
2945
+ if (!D->hasType ())
2946
+ TypeResolver->resolveDeclSignature (D);
2947
+
2940
2948
if (auto *EED = dyn_cast<EnumElementDecl>(D)) {
2941
2949
addEnumElementRef (EED, Reason, /* HasTypeContext=*/ true );
2942
2950
return true ;
2943
2951
} else if (auto *ED = dyn_cast<EnumDecl>(D)) {
2944
2952
llvm::DenseSet<EnumElementDecl *> Elements;
2945
2953
ED->getAllElements (Elements);
2946
2954
for (auto *Ele : Elements) {
2955
+ if (!Ele->hasType ())
2956
+ TypeResolver->resolveDeclSignature (Ele);
2947
2957
addEnumElementRef (Ele, Reason, /* HasTypeContext=*/ true );
2948
2958
}
2949
2959
return true ;
@@ -3655,7 +3665,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3655
3665
LookupByName Lookup (*this , FuncNames);
3656
3666
lookupVisibleDecls (Lookup, CurrDeclContext, TypeResolver.get (), true );
3657
3667
if (HasReturn)
3658
- Lookup.unboxType (getReturnTypeFromContext (CurrDeclContext));
3668
+ if (auto ReturnType = getReturnTypeFromContext (CurrDeclContext))
3669
+ Lookup.unboxType (ReturnType);
3659
3670
}
3660
3671
3661
3672
static bool getPositionInTupleExpr (DeclContext &DC, Expr *Target,
0 commit comments