@@ -816,37 +816,6 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
816
816
return ErrorType::get (ctx);
817
817
}
818
818
819
- // Build ParameterizedProtocolType if the protocol has a primary associated
820
- // type and we're in a supported context.
821
- if (resolution.getOptions ().isConstraintImplicitExistential () &&
822
- !ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
823
-
824
- if (!genericArgs.empty ()) {
825
-
826
- SmallVector<Type, 2 > argTys;
827
- for (auto *genericArg : genericArgs) {
828
- Type argTy = resolution.resolveType (genericArg);
829
- if (!argTy || argTy->hasError ())
830
- return ErrorType::get (ctx);
831
-
832
- argTys.push_back (argTy);
833
- }
834
-
835
- auto parameterized =
836
- ParameterizedProtocolType::get (ctx, protoType, argTys);
837
- diags.diagnose (loc, diag::existential_requires_any, parameterized,
838
- ExistentialType::get (parameterized),
839
- /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
840
- } else {
841
- diags.diagnose (loc, diag::existential_requires_any,
842
- protoDecl->getDeclaredInterfaceType (),
843
- protoDecl->getDeclaredExistentialType (),
844
- /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
845
- }
846
-
847
- return ErrorType::get (ctx);
848
- }
849
-
850
819
// Disallow opaque types anywhere in the structure of the generic arguments
851
820
// to a parameterized existential type.
852
821
if (options.is (TypeResolverContext::ExistentialConstraint))
@@ -855,6 +824,7 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
855
824
TypeResolverContext::ProtocolGenericArgument);
856
825
auto genericResolution = resolution.withOptions (argOptions);
857
826
827
+ // Resolve the generic arguments.
858
828
SmallVector<Type, 2 > argTys;
859
829
for (auto *genericArg : genericArgs) {
860
830
Type argTy = genericResolution.resolveType (genericArg, silContext);
@@ -864,7 +834,20 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
864
834
argTys.push_back (argTy);
865
835
}
866
836
867
- return ParameterizedProtocolType::get (ctx, protoType, argTys);
837
+ auto parameterized =
838
+ ParameterizedProtocolType::get (ctx, protoType, argTys);
839
+
840
+ // Build ParameterizedProtocolType if the protocol has primary associated
841
+ // types and we're in a supported context.
842
+ if (resolution.getOptions ().isConstraintImplicitExistential () &&
843
+ !ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
844
+ diags.diagnose (loc, diag::existential_requires_any, parameterized,
845
+ ExistentialType::get (parameterized),
846
+ /* isAlias=*/ isa<TypeAliasType>(type.getPointer ()));
847
+ return ErrorType::get (ctx);
848
+ }
849
+
850
+ return parameterized;
868
851
}
869
852
870
853
// We must either have an unbound generic type, or a generic type alias.
0 commit comments