@@ -2806,41 +2806,49 @@ CollectedOpaqueReprs swift::collectOpaqueReturnTypeReprs(TypeRepr *r, ASTContext
2806
2806
public:
2807
2807
explicit Walker (CollectedOpaqueReprs &reprs, ASTContext &ctx, DeclContext *d) : Reprs(reprs), Ctx(ctx), dc(d) {}
2808
2808
2809
- bool walkToTypeReprPre (TypeRepr *repr) override {
2810
- if (auto existential = dyn_cast<ExistentialTypeRepr>(repr)) {
2811
- auto generic = dyn_cast<GenericIdentTypeRepr>(existential->getConstraint ());
2812
- if (generic)
2813
- Reprs.push_back (existential);
2814
- auto meta = dyn_cast<MetatypeTypeRepr>(existential->getConstraint ());
2815
- return meta || generic? true : false ;
2816
- }
2809
+ PreWalkAction walkToTypeReprPre (TypeRepr *repr) override {
2810
+
2811
+ // Don't allow variadic opaque parameter or return types.
2812
+ if (isa<PackExpansionTypeRepr>(repr))
2813
+ return Action::SkipChildren ();
2817
2814
2818
2815
if (auto opaqueRepr = dyn_cast<OpaqueReturnTypeRepr>(repr)) {
2819
2816
Reprs.push_back (opaqueRepr);
2820
2817
if (Ctx.LangOpts .hasFeature (Feature::ImplicitSome))
2821
- return false ;
2818
+ return Action::SkipChildren () ;
2822
2819
}
2823
2820
2824
2821
if (Ctx.LangOpts .hasFeature (Feature::ImplicitSome)) {
2822
+
2823
+ if (auto existential = dyn_cast<ExistentialTypeRepr>(repr)) {
2824
+ auto generic = dyn_cast<GenericIdentTypeRepr>(existential->getConstraint ());
2825
+ if (generic)
2826
+ Reprs.push_back (existential);
2827
+ auto meta = dyn_cast<MetatypeTypeRepr>(existential->getConstraint ());
2828
+ Action::VisitChildrenIf (meta || generic);
2829
+ }
2830
+
2825
2831
if (auto compositionRepr = dyn_cast<CompositionTypeRepr>(repr)) {
2826
2832
if (!compositionRepr->isTypeReprAny ())
2827
2833
Reprs.push_back (compositionRepr);
2828
- return false ;
2834
+ return Action::SkipChildren () ;
2829
2835
} else if (auto generic = dyn_cast<GenericIdentTypeRepr>(repr)) {
2830
2836
if (!Reprs.empty ()){
2831
2837
if (isa<ExistentialTypeRepr>(Reprs.front ())){
2832
2838
Reprs.clear ();
2833
- return true ;
2839
+ Action::Continue () ;
2834
2840
}
2835
2841
}
2836
2842
Reprs.push_back (generic);
2837
2843
} else if (auto identRepr = dyn_cast<IdentTypeRepr>(repr)) {
2838
2844
if (identRepr->isProtocol (dc))
2839
2845
Reprs.push_back (identRepr);
2840
2846
}
2847
+
2841
2848
}
2842
- return true ;
2849
+ return Action::Continue () ;
2843
2850
}
2851
+
2844
2852
};
2845
2853
2846
2854
CollectedOpaqueReprs reprs;
0 commit comments