@@ -758,14 +758,32 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
758
758
}
759
759
760
760
// Build ParameterizedProtocolType if the protocol has a primary associated
761
- // type and we're in a supported context (for now just generic requirements,
762
- // inheritance clause, extension binding).
761
+ // type and we're in a supported context.
763
762
if (resolution.getOptions ().isConstraintImplicitExistential () &&
764
763
!ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
765
- diags.diagnose (loc, diag::existential_requires_any,
766
- protoDecl->getDeclaredInterfaceType (),
767
- protoDecl->getDeclaredExistentialType (),
768
- /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
764
+
765
+ if (!genericArgs.empty ()) {
766
+
767
+ SmallVector<Type, 2 > argTys;
768
+ for (auto *genericArg : genericArgs) {
769
+ Type argTy = resolution.resolveType (genericArg);
770
+ if (!argTy || argTy->hasError ())
771
+ return ErrorType::get (ctx);
772
+
773
+ argTys.push_back (argTy);
774
+ }
775
+
776
+ auto parameterized =
777
+ ParameterizedProtocolType::get (ctx, protoType, argTys);
778
+ diags.diagnose (loc, diag::existential_requires_any, parameterized,
779
+ ExistentialType::get (parameterized),
780
+ /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
781
+ } else {
782
+ diags.diagnose (loc, diag::existential_requires_any,
783
+ protoDecl->getDeclaredInterfaceType (),
784
+ protoDecl->getDeclaredExistentialType (),
785
+ /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
786
+ }
769
787
770
788
return ErrorType::get (ctx);
771
789
}
0 commit comments