@@ -629,15 +629,8 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
629629 auto &diags = ctx.Diags ;
630630
631631 if (auto *protoType = type->getAs <ProtocolType>()) {
632- // Build ParameterizedProtocolType if the protocol has a primary associated
633- // type and we're in a supported context (for now just generic requirements,
634- // inheritance clause, extension binding).
635- if (!resolution.getOptions ().isParameterizedProtocolSupported ()) {
636- diags.diagnose (loc, diag::parameterized_protocol_not_supported);
637- return ErrorType::get (ctx);
638- }
639-
640632 auto *protoDecl = protoType->getDecl ();
633+
641634 auto assocTypes = protoDecl->getPrimaryAssociatedTypes ();
642635 if (assocTypes.empty ()) {
643636 diags.diagnose (loc, diag::protocol_does_not_have_primary_assoc_type,
@@ -657,6 +650,18 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
657650 return ErrorType::get (ctx);
658651 }
659652
653+ // Build ParameterizedProtocolType if the protocol has a primary associated
654+ // type and we're in a supported context (for now just generic requirements,
655+ // inheritance clause, extension binding).
656+ if (!resolution.getOptions ().isParameterizedProtocolSupported ()) {
657+ diags.diagnose (loc, diag::existential_requires_any,
658+ protoDecl->getDeclaredInterfaceType (),
659+ protoDecl->getExistentialType (),
660+ /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
661+
662+ return ErrorType::get (ctx);
663+ }
664+
660665 // Disallow opaque types anywhere in the structure of the generic arguments
661666 // to a parameterized existential type.
662667 if (options.is (TypeResolverContext::ExistentialConstraint))
0 commit comments