@@ -770,37 +770,6 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
770
770
return ErrorType::get (ctx);
771
771
}
772
772
773
- // Build ParameterizedProtocolType if the protocol has a primary associated
774
- // type and we're in a supported context.
775
- if (resolution.getOptions ().isConstraintImplicitExistential () &&
776
- !ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
777
-
778
- if (!genericArgs.empty ()) {
779
-
780
- SmallVector<Type, 2 > argTys;
781
- for (auto *genericArg : genericArgs) {
782
- Type argTy = resolution.resolveType (genericArg);
783
- if (!argTy || argTy->hasError ())
784
- return ErrorType::get (ctx);
785
-
786
- argTys.push_back (argTy);
787
- }
788
-
789
- auto parameterized =
790
- ParameterizedProtocolType::get (ctx, protoType, argTys);
791
- diags.diagnose (loc, diag::existential_requires_any, parameterized,
792
- ExistentialType::get (parameterized),
793
- /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
794
- } else {
795
- diags.diagnose (loc, diag::existential_requires_any,
796
- protoDecl->getDeclaredInterfaceType (),
797
- protoDecl->getDeclaredExistentialType (),
798
- /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
799
- }
800
-
801
- return ErrorType::get (ctx);
802
- }
803
-
804
773
// Disallow opaque types anywhere in the structure of the generic arguments
805
774
// to a parameterized existential type.
806
775
if (options.is (TypeResolverContext::ExistentialConstraint))
@@ -809,6 +778,7 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
809
778
TypeResolverContext::ProtocolGenericArgument);
810
779
auto genericResolution = resolution.withOptions (argOptions);
811
780
781
+ // Resolve the generic arguments.
812
782
SmallVector<Type, 2 > argTys;
813
783
for (auto *genericArg : genericArgs) {
814
784
Type argTy = genericResolution.resolveType (genericArg, silContext);
@@ -818,7 +788,20 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
818
788
argTys.push_back (argTy);
819
789
}
820
790
821
- return ParameterizedProtocolType::get (ctx, protoType, argTys);
791
+ auto parameterized =
792
+ ParameterizedProtocolType::get (ctx, protoType, argTys);
793
+
794
+ // Build ParameterizedProtocolType if the protocol has primary associated
795
+ // types and we're in a supported context.
796
+ if (resolution.getOptions ().isConstraintImplicitExistential () &&
797
+ !ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
798
+ diags.diagnose (loc, diag::existential_requires_any, parameterized,
799
+ ExistentialType::get (parameterized),
800
+ /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
801
+ return ErrorType::get (ctx);
802
+ }
803
+
804
+ return parameterized;
822
805
}
823
806
824
807
// We must either have an unbound generic type, or a generic type alias.
0 commit comments