@@ -134,12 +134,17 @@ namespace {
134
134
}
135
135
136
136
public:
137
- explicit Space (Type T)
137
+ explicit
138
+ Space (Type T)
138
139
: Kind (SpaceKind::Type), TypeAndVal (T, false ), Head (Identifier ()),
139
140
Spaces ({}){}
140
141
explicit Space (Type T, Identifier H, bool downgrade, SmallVectorImpl<Space> &SP)
141
142
: Kind (SpaceKind::Constructor), TypeAndVal (T, downgrade), Head (H),
142
143
Spaces (SP.begin (), SP.end ()) {}
144
+ explicit Space (Type T, Identifier H, bool downgrade,
145
+ const std::forward_list<Space> &SP)
146
+ : Kind (SpaceKind::Constructor), TypeAndVal (T, downgrade), Head (H),
147
+ Spaces (SP.begin (), SP.end ()) {}
143
148
explicit Space (SmallVectorImpl<Space> &SP)
144
149
: Kind (SpaceKind::Disjunct), TypeAndVal (Type (), false ),
145
150
Head (Identifier ()), Spaces (SP.begin (), SP.end ()) {}
@@ -1267,6 +1272,14 @@ namespace {
1267
1272
}
1268
1273
case PatternKind::OptionalSome: {
1269
1274
auto *OSP = cast<OptionalSomePattern>(item);
1275
+ auto subSpace = projectPattern (TC, OSP->getSubPattern (), sawDowngradablePattern);
1276
+ // To match patterns like (_, _, ...)?, we must rewrite the underlying
1277
+ // tuple pattern to .some(_, _, ...) first.
1278
+ if (subSpace.getKind () == SpaceKind::Constructor
1279
+ && subSpace.getHead ().empty ()) {
1280
+ return Space (item->getType (), TC.Context .getIdentifier (" some" ),
1281
+ /* canDowngrade*/ false , subSpace.getSpaces ());
1282
+ }
1270
1283
SmallVector<Space, 1 > payload = {
1271
1284
projectPattern (TC, OSP->getSubPattern (), sawDowngradablePattern)
1272
1285
};
0 commit comments