@@ -645,52 +645,47 @@ static void lookupVisibleMemberDeclsImpl(
645
645
return ;
646
646
647
647
synthesizeAndLookupTypeMembers (NTD);
648
+ // Look into protocols only on the current nominal to avoid repeatedly
649
+ // visiting inherited conformances.
648
650
lookupDeclsFromProtocolsBeingConformedTo (BaseTy, Consumer, LS, CurrDC,
649
651
Reason, Visited);
650
652
651
653
const auto CD = dyn_cast<ClassDecl>(NTD);
654
+
652
655
// FIXME: We check `getSuperclass()` here because we'll be using the
653
656
// superclass Type below, and in ill-formed code `hasSuperclass()` could
654
657
// be true while `getSuperclass()` returns null, because the latter
655
658
// looks for a declaration.
656
- //
657
- // If we have a superclass, switch state and look into the
658
- // inheritance chain.
659
- if (CD && CD->getSuperclass ()) {
660
- Ancestors.insert (CD);
661
-
662
- Reason = getReasonForSuper (Reason);
663
- BaseTy = CD->getSuperclass ();
664
-
665
- LS = LS.withOnSuperclass ();
666
- if (CD->inheritsSuperclassInitializers ())
667
- LS = LS.withInheritsSuperclassInitializers ();
668
- } else {
659
+ if (!CD || !CD->getSuperclass ())
669
660
return ;
670
- }
661
+
662
+ // We have a superclass; switch state and look into the inheritance chain.
663
+ Ancestors.insert (CD);
664
+
665
+ Reason = getReasonForSuper (Reason);
666
+ BaseTy = CD->getSuperclass ();
667
+
668
+ LS = LS.withOnSuperclass ();
669
+ if (CD->inheritsSuperclassInitializers ())
670
+ LS = LS.withInheritsSuperclassInitializers ();
671
671
}
672
672
673
673
// Look into the inheritance chain.
674
- while (const auto CurClass = cast_or_null<ClassDecl>(
675
- BaseTy->getAnyNominal ())) {
676
- synthesizeAndLookupTypeMembers (CurClass);
677
- if (const auto superclassTy = CurClass->getSuperclass ()) {
678
- // FIXME: This path is no substitute for an actual circularity check.
679
- // The real fix is to check that the superclass doesn't introduce a
680
- // circular reference before it's written into the AST.
681
- if (Ancestors.count (CurClass)) {
682
- break ;
683
- }
684
- Ancestors.insert (CurClass);
685
-
686
- BaseTy = superclassTy;
674
+ do {
675
+ const auto CurClass = BaseTy->getClassOrBoundGenericClass ();
687
676
688
- if (!CurClass->inheritsSuperclassInitializers ())
689
- LS = LS.withoutInheritsSuperclassInitializers ();
690
- } else {
677
+ // FIXME: This path is no substitute for an actual circularity check.
678
+ // The real fix is to check that the superclass doesn't introduce a
679
+ // circular reference before it's written into the AST.
680
+ if (!Ancestors.insert (CurClass).second )
691
681
break ;
692
- }
693
- }
682
+
683
+ synthesizeAndLookupTypeMembers (CurClass);
684
+
685
+ BaseTy = CurClass->getSuperclass ();
686
+ if (!CurClass->inheritsSuperclassInitializers ())
687
+ LS = LS.withoutInheritsSuperclassInitializers ();
688
+ } while (BaseTy);
694
689
}
695
690
696
691
swift::DynamicLookupInfo::DynamicLookupInfo (
0 commit comments