@@ -1090,30 +1090,36 @@ Type StructuralTypeRequest::evaluate(Evaluator &evaluator,
10901090 ? TypeResolverContext::GenericTypeAliasDecl
10911091 : TypeResolverContext::TypeAliasDecl));
10921092
1093+ auto parentDC = typeAlias->getDeclContext ();
1094+ auto &ctx = parentDC->getASTContext ();
1095+
1096+ auto underlyingTypeRepr = typeAlias->getUnderlyingTypeRepr ();
1097+
10931098 // This can happen when code completion is attempted inside
10941099 // of typealias underlying type e.g. `typealias F = () -> Int#^TOK^#`
1095- auto &ctx = typeAlias->getASTContext ();
1096- auto underlyingTypeRepr = typeAlias->getUnderlyingTypeRepr ();
10971100 if (!underlyingTypeRepr) {
10981101 typeAlias->setInvalid ();
10991102 return ErrorType::get (ctx);
11001103 }
11011104
1102- const auto type =
1103- TypeResolution::forStructural (typeAlias, options,
1104- /* unboundTyOpener*/ nullptr ,
1105- /* placeholderHandler*/ nullptr ,
1106- /* packElementOpener*/ nullptr )
1105+ auto result = TypeResolution::forStructural (typeAlias, options,
1106+ /* unboundTyOpener*/ nullptr ,
1107+ /* placeholderHandler*/ nullptr ,
1108+ /* packElementOpener*/ nullptr )
11071109 .resolveType (underlyingTypeRepr);
11081110
1111+ // Don't build a generic siganture for a protocol extension, because this
1112+ // request might be evaluated while building a protocol requirement signature.
1113+ if (parentDC->getSelfProtocolDecl ())
1114+ return result;
1115+
11091116 auto genericSig = typeAlias->getGenericSignature ();
11101117 SubstitutionMap subs;
11111118 if (genericSig)
11121119 subs = genericSig->getIdentitySubstitutionMap ();
11131120
11141121 Type parent;
1115- auto parentDC = typeAlias->getDeclContext ();
11161122 if (parentDC->isTypeContext ())
11171123 parent = parentDC->getSelfInterfaceType ();
1118- return TypeAliasType::get (typeAlias, parent, subs, type );
1124+ return TypeAliasType::get (typeAlias, parent, subs, result );
11191125}
0 commit comments