@@ -628,50 +628,48 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
628628 auto &ctx = dc->getASTContext ();
629629 auto &diags = ctx.Diags ;
630630
631- if (ctx.LangOpts .EnableParameterizedProtocolTypes ) {
632- if (auto *protoType = type->getAs <ProtocolType>()) {
633- // Build ParameterizedProtocolType if the protocol has a primary associated
634- // type and we're in a supported context (for now just generic requirements,
635- // inheritance clause, extension binding).
636- if (!resolution.getOptions ().isParameterizedProtocolSupported ()) {
637- diags.diagnose (loc, diag::parameterized_protocol_not_supported);
638- return ErrorType::get (ctx);
639- }
631+ 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 (ctx.LangOpts )) {
636+ diags.diagnose (loc, diag::parameterized_protocol_not_supported);
637+ return ErrorType::get (ctx);
638+ }
640639
641- auto *protoDecl = protoType->getDecl ();
642- auto assocTypes = protoDecl->getPrimaryAssociatedTypes ();
643- if (assocTypes.empty ()) {
644- diags.diagnose (loc, diag::protocol_does_not_have_primary_assoc_type,
645- protoType);
640+ auto *protoDecl = protoType->getDecl ();
641+ auto assocTypes = protoDecl->getPrimaryAssociatedTypes ();
642+ if (assocTypes.empty ()) {
643+ diags.diagnose (loc, diag::protocol_does_not_have_primary_assoc_type,
644+ protoType);
646645
647- return ErrorType::get (ctx);
648- }
649-
650- auto genericArgs = generic->getGenericArgs ();
646+ return ErrorType::get (ctx);
647+ }
651648
652- if (genericArgs.size () != assocTypes.size ()) {
653- diags.diagnose (loc,
654- diag::parameterized_protocol_type_argument_count_mismatch,
655- protoType, genericArgs.size (), assocTypes.size (),
656- (genericArgs.size () < assocTypes.size ()) ? 1 : 0 );
649+ auto genericArgs = generic->getGenericArgs ();
657650
658- return ErrorType::get (ctx);
659- }
651+ if (genericArgs.size () != assocTypes.size ()) {
652+ diags.diagnose (loc,
653+ diag::parameterized_protocol_type_argument_count_mismatch,
654+ protoType, genericArgs.size (), assocTypes.size (),
655+ (genericArgs.size () < assocTypes.size ()) ? 1 : 0 );
660656
661- auto genericResolution =
662- resolution. withOptions ( adjustOptionsForGenericArgs (options));
657+ return ErrorType::get (ctx);
658+ }
663659
664- SmallVector<Type, 2 > argTys;
665- for (auto *genericArg : genericArgs) {
666- Type argTy = genericResolution.resolveType (genericArg, silParams);
667- if (!argTy || argTy->hasError ())
668- return ErrorType::get (ctx);
660+ auto genericResolution =
661+ resolution.withOptions (adjustOptionsForGenericArgs (options));
669662
670- argTys.push_back (argTy);
671- }
663+ SmallVector<Type, 2 > argTys;
664+ for (auto *genericArg : genericArgs) {
665+ Type argTy = genericResolution.resolveType (genericArg, silParams);
666+ if (!argTy || argTy->hasError ())
667+ return ErrorType::get (ctx);
672668
673- return ParameterizedProtocolType::get (ctx, protoType, argTys);
669+ argTys. push_back (argTy );
674670 }
671+
672+ return ParameterizedProtocolType::get (ctx, protoType, argTys);
675673 }
676674
677675 // We must either have an unbound generic type, or a generic type alias.
0 commit comments