Skip to content

Commit ca99c18

Browse files
committed
[NameLookup] Opaque Type Collector should skip existential types
1 parent ea5d281 commit ca99c18

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,11 +2846,7 @@ CollectedOpaqueReprs swift::collectOpaqueReturnTypeReprs(TypeRepr *r, ASTContext
28462846
return Action::Continue();
28472847

28482848
if (auto existential = dyn_cast<ExistentialTypeRepr>(repr)) {
2849-
auto meta = dyn_cast<MetatypeTypeRepr>(existential->getConstraint());
2850-
auto generic = dyn_cast<GenericIdentTypeRepr>(existential->getConstraint());
2851-
if(generic)
2852-
Reprs.push_back(existential);
2853-
return Action::VisitChildrenIf(meta || generic);
2849+
return Action::SkipChildren();
28542850
} else if (auto compositionRepr = dyn_cast<CompositionTypeRepr>(repr)) {
28552851
if (!compositionRepr->isTypeReprAny())
28562852
Reprs.push_back(compositionRepr);

lib/Sema/TypeCheckPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ validateTypedPattern(TypedPattern *TP, DeclContext *dc,
742742
auto *Repr = TP->getTypeRepr();
743743
if (Repr && (Repr->hasOpaque() ||
744744
(Context.LangOpts.hasFeature(Feature::ImplicitSome) &&
745-
Repr->isProtocol(dc)))) {
745+
!collectOpaqueReturnTypeReprs(Repr, Context, dc).empty()))) {
746746
auto named = dyn_cast<NamedPattern>(
747747
TP->getSubPattern()->getSemanticsProvidingPattern());
748748
if (!named) {

0 commit comments

Comments
 (0)