@@ -2638,6 +2638,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2638
2638
for (auto *init : initializers) {
2639
2639
if (shouldHideDeclFromCompletionResults (init))
2640
2640
continue ;
2641
+ if (IsUnresolvedMember &&
2642
+ cast<ConstructorDecl>(init)->getFailability () == OTK_Optional) {
2643
+ continue ;
2644
+ }
2641
2645
addConstructorCall (cast<ConstructorDecl>(init), Reason, type, None,
2642
2646
/* IsOnType=*/ true , name);
2643
2647
}
@@ -3786,6 +3790,9 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3786
3790
// same result type) as the contextual type.
3787
3791
FilteredDeclConsumer consumer (*this , [=](ValueDecl *VD,
3788
3792
DeclVisibilityKind reason) {
3793
+ if (VD->isOperator ())
3794
+ return false ;
3795
+
3789
3796
if (!VD->hasInterfaceType ()) {
3790
3797
TypeResolver->resolveDeclSignature (VD);
3791
3798
if (!VD->hasInterfaceType ())
@@ -3819,6 +3826,11 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3819
3826
// convertible to the contextual type.
3820
3827
if (auto CD = dyn_cast<TypeDecl>(VD)) {
3821
3828
declTy = declTy->getMetatypeInstanceType ();
3829
+
3830
+ // Emit construction for the same type via typealias doesn't make sense
3831
+ // because we are emitting all `.init()`s.
3832
+ if (declTy->isEqual (T))
3833
+ return false ;
3822
3834
return swift::isConvertibleTo (declTy, T, *DC);
3823
3835
}
3824
3836
@@ -3836,7 +3848,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3836
3848
// FIXME: This emits just 'factory'. We should emit 'factory()' instead.
3837
3849
declTy = FT->getResult ();
3838
3850
}
3839
- return swift::isConvertibleTo (declTy, T, *DC);
3851
+ return declTy-> isEqual (T) || swift::isConvertibleTo (declTy, T, *DC);
3840
3852
});
3841
3853
3842
3854
auto baseType = MetatypeType::get (T);
0 commit comments