@@ -33,7 +33,7 @@ using namespace swift;
3333bool swift::decodeRegexCaptureTypes (ASTContext &ctx,
3434 ArrayRef<uint8_t > serialization,
3535 Type atomType,
36- SmallVectorImpl<TupleTypeElt > &result) {
36+ SmallVectorImpl<Type > &result) {
3737 using Version = RegexLiteralExpr::CaptureStructureSerializationVersion;
3838 static const Version implVersion = 1 ;
3939 unsigned size = serialization.size ();
@@ -46,7 +46,7 @@ bool swift::decodeRegexCaptureTypes(ASTContext &ctx,
4646 if (version != implVersion)
4747 return true ;
4848 // Read contents.
49- SmallVector<SmallVector<TupleTypeElt , 4 >, 4 > scopes (1 );
49+ SmallVector<SmallVector<Type , 4 >, 4 > scopes (1 );
5050 unsigned offset = sizeof (Version);
5151 auto consumeCode = [&]() -> Optional<RegexCaptureStructureCode> {
5252 auto rawValue = serialization[offset];
@@ -73,29 +73,33 @@ bool swift::decodeRegexCaptureTypes(ASTContext &ctx,
7373 if (length >= size - offset)
7474 return true ; // Unterminated string.
7575 StringRef name (namePtr, length);
76- scopes.back ().push_back (
77- TupleTypeElt (atomType, ctx.getIdentifier (name)));
76+ // The name is currently unused becuase we are forming a nominal
77+ // `Tuple{n}` type. We will switch back to native tuples when there is
78+ // variadic generics.
79+ (void )name;
80+ scopes.back ().push_back (atomType);
7881 offset += length + /* NUL*/ 1 ;
7982 break ;
8083 }
8184 case RegexCaptureStructureCode::FormArray: {
82- auto &element = scopes.back ().back ();
83- element = TupleTypeElt (ArraySliceType::get (element.getType ()),
84- element.getName ());
85+ auto &type = scopes.back ().back ();
86+ type = ArraySliceType::get (type);
8587 break ;
8688 }
8789 case RegexCaptureStructureCode::FormOptional: {
88- auto &element = scopes.back ().back ();
89- element = TupleTypeElt (OptionalType::get (element.getType ()),
90- element.getName ());
90+ auto &type = scopes.back ().back ();
91+ type = OptionalType::get (type);
9192 break ;
9293 }
9394 case RegexCaptureStructureCode::BeginTuple:
9495 scopes.push_back ({});
9596 break ;
9697 case RegexCaptureStructureCode::EndTuple: {
9798 auto children = scopes.pop_back_val ();
98- auto type = TupleType::get (children, ctx);
99+ if (children.size () > ctx.getStringProcessingTupleDeclMaxArity ())
100+ return true ;
101+ auto tupleDecl = ctx.getStringProcessingTupleDecl (children.size ());
102+ auto type = BoundGenericStructType::get (tupleDecl, Type (), children);
99103 scopes.back ().push_back (type);
100104 break ;
101105 }
0 commit comments