@@ -1283,21 +1283,22 @@ class NameAliasType : public TypeBase {
12831283//
12841284// / Provide parameter type relevant flags, i.e. variadic, autoclosure, and
12851285// / escaping.
1286- struct ParameterTypeFlags {
1287- uint8_t value;
1288- enum : uint8_t {
1286+ class ParameterTypeFlags {
1287+ enum ParameterFlags : uint8_t {
12891288 None = 0 ,
12901289 Variadic = 1 << 0 ,
12911290 AutoClosure = 1 << 1 ,
12921291 Escaping = 1 << 2 ,
12931292
12941293 NumBits = 3
12951294 };
1295+ OptionSet<ParameterFlags> value;
12961296 static_assert (NumBits < 8 *sizeof (value), " overflowed" );
12971297
1298- ParameterTypeFlags () : value(None ) {}
1298+ ParameterTypeFlags (OptionSet<ParameterFlags, uint8_t > val ) : value(val ) {}
12991299
1300- ParameterTypeFlags (uint8_t val) : value(val) {}
1300+ public:
1301+ ParameterTypeFlags () = default ;
13011302
13021303 ParameterTypeFlags (bool variadic, bool autoclosure, bool escaping)
13031304 : value((variadic ? Variadic : 0 ) |
@@ -1308,13 +1309,21 @@ struct ParameterTypeFlags {
13081309 inline static ParameterTypeFlags fromParameterType (Type paramTy,
13091310 bool isVariadic);
13101311
1311- bool isVariadic () const { return 0 != (value & Variadic); }
1312- bool isAutoClosure () const { return 0 != (value & AutoClosure); }
1313- bool isEscaping () const { return 0 != (value & Escaping); }
1312+ bool isNone () const { return !value; }
1313+ bool isVariadic () const { return value.contains (Variadic); }
1314+ bool isAutoClosure () const { return value.contains (AutoClosure); }
1315+ bool isEscaping () const { return value.contains (Escaping); }
1316+
1317+ ParameterTypeFlags withEscaping (bool escaping) const {
1318+ return ParameterTypeFlags (escaping ? value | ParameterTypeFlags::Escaping
1319+ : value - ParameterTypeFlags::Escaping);
1320+ }
13141321
1315- bool operator ==(const ParameterTypeFlags &other) {
1316- return value == other.value ;
1322+ bool operator ==(const ParameterTypeFlags &other) const {
1323+ return value. toRaw () == other.value . toRaw () ;
13171324 }
1325+
1326+ uint8_t toRaw () const { return value.toRaw (); }
13181327};
13191328
13201329// / ParenType - A paren type is a type that's been written in parentheses.
@@ -1399,21 +1408,16 @@ class TupleTypeElt {
13991408
14001409 // / Retrieve a copy of this tuple type element with the type replaced.
14011410 TupleTypeElt getWithType (Type T) const {
1402- return TupleTypeElt (T, getName (), isVararg (), isAutoClosure (),
1403- isEscaping ());
1411+ return TupleTypeElt (T, getName (), getParameterFlags ());
14041412 }
14051413
14061414 // / Retrieve a copy of this tuple type element with the name replaced.
1407- TupleTypeElt getWithName (Identifier name = Identifier()) const {
1408- return TupleTypeElt (getType (), name, isVararg (), isAutoClosure (),
1409- isEscaping ());
1415+ TupleTypeElt getWithName (Identifier name) const {
1416+ return TupleTypeElt (getType (), name, getParameterFlags ());
14101417 }
14111418
1412- // / Retrieve a copy of this tuple type element with the type and name
1413- // / replaced.
1414- TupleTypeElt getWithTypeAndName (Type T, Identifier name) const {
1415- return TupleTypeElt (T, name, isVararg (), isAutoClosure (), isEscaping ());
1416- }
1419+ // / Retrieve a copy of this tuple type element with no name
1420+ TupleTypeElt getWithoutName () const { return getWithName (Identifier ()); }
14171421};
14181422
14191423inline Type getTupleEltType (const TupleTypeElt &elt) {
0 commit comments