@@ -1090,30 +1090,36 @@ Type StructuralTypeRequest::evaluate(Evaluator &evaluator,
1090
1090
? TypeResolverContext::GenericTypeAliasDecl
1091
1091
: TypeResolverContext::TypeAliasDecl));
1092
1092
1093
+ auto parentDC = typeAlias->getDeclContext ();
1094
+ auto &ctx = parentDC->getASTContext ();
1095
+
1096
+ auto underlyingTypeRepr = typeAlias->getUnderlyingTypeRepr ();
1097
+
1093
1098
// This can happen when code completion is attempted inside
1094
1099
// of typealias underlying type e.g. `typealias F = () -> Int#^TOK^#`
1095
- auto &ctx = typeAlias->getASTContext ();
1096
- auto underlyingTypeRepr = typeAlias->getUnderlyingTypeRepr ();
1097
1100
if (!underlyingTypeRepr) {
1098
1101
typeAlias->setInvalid ();
1099
1102
return ErrorType::get (ctx);
1100
1103
}
1101
1104
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 )
1107
1109
.resolveType (underlyingTypeRepr);
1108
1110
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
+
1109
1116
auto genericSig = typeAlias->getGenericSignature ();
1110
1117
SubstitutionMap subs;
1111
1118
if (genericSig)
1112
1119
subs = genericSig->getIdentitySubstitutionMap ();
1113
1120
1114
1121
Type parent;
1115
- auto parentDC = typeAlias->getDeclContext ();
1116
1122
if (parentDC->isTypeContext ())
1117
1123
parent = parentDC->getSelfInterfaceType ();
1118
- return TypeAliasType::get (typeAlias, parent, subs, type );
1124
+ return TypeAliasType::get (typeAlias, parent, subs, result );
1119
1125
}
0 commit comments