@@ -705,14 +705,16 @@ StructuralRequirementsRequest::evaluate(Evaluator &evaluator,
705
705
// underlying type of the typealias.
706
706
if (auto *typeAliasDecl = dyn_cast<TypeAliasDecl>(decl)) {
707
707
if (!typeAliasDecl->isGeneric ()) {
708
- // Ignore the typealias if we have an associated type with the same anme
708
+ // Ignore the typealias if we have an associated type with the same name
709
709
// in the same protocol. This is invalid anyway, but it's just here to
710
710
// ensure that we produce the same requirement signature on some tests
711
711
// with -requirement-machine-protocol-signatures=verify.
712
712
if (assocTypes.contains (typeAliasDecl->getName ()))
713
713
continue ;
714
714
715
715
auto underlyingType = typeAliasDecl->getStructuralType ();
716
+ if (underlyingType->is <UnboundGenericType>())
717
+ continue ;
716
718
717
719
auto subjectType = DependentMemberType::get (
718
720
selfTy, typeAliasDecl->getName ());
@@ -752,6 +754,20 @@ TypeAliasRequirementsRequest::evaluate(Evaluator &evaluator,
752
754
(ctx.LangOpts .RequirementMachineProtocolSignatures ==
753
755
RequirementMachineMode::Enabled);
754
756
757
+ auto getStructuralType = [](TypeDecl *typeDecl) -> Type {
758
+ if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) {
759
+ if (typealias->getUnderlyingTypeRepr () != nullptr ) {
760
+ auto type = typealias->getStructuralType ();
761
+ if (auto *aliasTy = cast<TypeAliasType>(type.getPointer ()))
762
+ return aliasTy->getSinglyDesugaredType ();
763
+ return type;
764
+ }
765
+ return typealias->getUnderlyingType ();
766
+ }
767
+
768
+ return typeDecl->getDeclaredInterfaceType ();
769
+ };
770
+
755
771
// Collect all typealiases from inherited protocols recursively.
756
772
llvm::MapVector<Identifier, TinyPtrVector<TypeDecl *>> inheritedTypeDecls;
757
773
for (auto *inheritedProto : ctx.getRewriteContext ().getInheritedProtocols (proto)) {
@@ -762,25 +778,17 @@ TypeAliasRequirementsRequest::evaluate(Evaluator &evaluator,
762
778
if (genReq->getGenericParams ())
763
779
continue ;
764
780
781
+ // Ignore typealiases with UnboundGenericType, since they
782
+ // are like generic typealiases.
783
+ if (auto *typeAlias = dyn_cast<TypeAliasDecl>(req))
784
+ if (getStructuralType (typeAlias)->is <UnboundGenericType>())
785
+ continue ;
786
+
765
787
inheritedTypeDecls[typeReq->getName ()].push_back (typeReq);
766
788
}
767
789
}
768
790
}
769
791
770
- auto getStructuralType = [](TypeDecl *typeDecl) -> Type {
771
- if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) {
772
- if (typealias->getUnderlyingTypeRepr () != nullptr ) {
773
- auto type = typealias->getStructuralType ();
774
- if (auto *aliasTy = cast<TypeAliasType>(type.getPointer ()))
775
- return aliasTy->getSinglyDesugaredType ();
776
- return type;
777
- }
778
- return typealias->getUnderlyingType ();
779
- }
780
-
781
- return typeDecl->getDeclaredInterfaceType ();
782
- };
783
-
784
792
// An inferred same-type requirement between the two type declarations
785
793
// within this protocol or a protocol it inherits.
786
794
auto recordInheritedTypeRequirement = [&](TypeDecl *first, TypeDecl *second) {
0 commit comments