@@ -1061,13 +1061,13 @@ class SILBoxTypeReprField {
10611061 TypeRepr *getFieldType () const { return FieldTypeAndMutable.getPointer (); }
10621062 bool isMutable () const { return FieldTypeAndMutable.getInt (); }
10631063};
1064-
1065- // / TypeRepr for opaque return types.
1064+
1065+ // / A TypeRepr for anonymous opaque return types.
10661066// /
1067- // / This can occur in the return position of a function declaration, or the
1068- // / top-level type of a property, to specify that the concrete return type
1069- // / should be abstracted from callers, given a set of generic constraints that
1070- // / the concrete return type satisfies:
1067+ // / This can occur in the return type of a function declaration, or the type of
1068+ // / a property, to specify that the concrete return type should be abstracted
1069+ // / from callers, given a set of generic constraints that the concrete return
1070+ // / type satisfies:
10711071// /
10721072// / func foo() -> some Collection { return [1,2,3] }
10731073// / var bar: some SignedInteger = 1
@@ -1101,6 +1101,42 @@ class OpaqueReturnTypeRepr : public TypeRepr {
11011101 friend class TypeRepr ;
11021102};
11031103
1104+ // / A TypeRepr for a type with a generic parameter list of named opaque return
1105+ // / types.
1106+ // /
1107+ // / This can occur only as the return type of a function declaration, to specify
1108+ // / subtypes which should be abstracted from callers, given a set of generic
1109+ // / constraints that the concrete types satisfy:
1110+ // /
1111+ // / func foo() -> <T: Collection> T { return [1] }
1112+ class OpaqueReturnParameterizedTypeRepr : public TypeRepr {
1113+ TypeRepr *Base;
1114+ GenericParamList *GenericParams;
1115+
1116+ public:
1117+ OpaqueReturnParameterizedTypeRepr (TypeRepr *Base,
1118+ GenericParamList *GenericParams)
1119+ : TypeRepr(TypeReprKind::OpaqueReturnParameterized), Base(Base),
1120+ GenericParams (GenericParams) {}
1121+
1122+ TypeRepr *getBase () const { return Base; }
1123+ GenericParamList *getGenericParams () const { return GenericParams; }
1124+
1125+ static bool classof (const TypeRepr *T) {
1126+ return T->getKind () == TypeReprKind::OpaqueReturnParameterized;
1127+ }
1128+ static bool classof (const OpaqueReturnParameterizedTypeRepr *T) {
1129+ return true ;
1130+ }
1131+
1132+ private:
1133+ SourceLoc getStartLocImpl () const ;
1134+ SourceLoc getEndLocImpl () const ;
1135+ SourceLoc getLocImpl () const ;
1136+ void printImpl (ASTPrinter &Printer, const PrintOptions &Opts) const ;
1137+ friend class TypeRepr ;
1138+ };
1139+
11041140// / TypeRepr for a user-specified placeholder (essentially, a user-facing
11051141// / representation of an anonymous type variable.
11061142// /
@@ -1245,6 +1281,8 @@ inline bool TypeRepr::isSimple() const {
12451281 case TypeReprKind::Isolated:
12461282 case TypeReprKind::Placeholder:
12471283 return true ;
1284+ case TypeReprKind::OpaqueReturnParameterized:
1285+ return cast<OpaqueReturnParameterizedTypeRepr>(this )->getBase ()->isSimple ();
12481286 }
12491287 llvm_unreachable (" bad TypeRepr kind" );
12501288}
0 commit comments