@@ -33,7 +33,7 @@ using namespace swift;
3333bool swift::decodeRegexCaptureTypes (ASTContext &ctx,
3434 ArrayRef<uint8_t > serialization,
3535 Type atomType,
36- SmallVectorImpl<Type > &result) {
36+ SmallVectorImpl<TupleTypeElt > &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<Type , 4 >, 4 > scopes (1 );
49+ SmallVector<SmallVector<TupleTypeElt , 4 >, 4 > scopes (1 );
5050 unsigned offset = sizeof (Version);
5151 auto consumeCode = [&]() -> Optional<RegexCaptureStructureCode> {
5252 auto rawValue = serialization[offset];
@@ -73,33 +73,29 @@ bool swift::decodeRegexCaptureTypes(ASTContext &ctx,
7373 if (length >= size - offset)
7474 return true ; // Unterminated string.
7575 StringRef name (namePtr, length);
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);
76+ scopes.back ().push_back (
77+ TupleTypeElt (atomType, ctx.getIdentifier (name)));
8178 offset += length + /* NUL*/ 1 ;
8279 break ;
8380 }
8481 case RegexCaptureStructureCode::FormArray: {
85- auto &type = scopes.back ().back ();
86- type = ArraySliceType::get (type);
82+ auto &element = scopes.back ().back ();
83+ element = TupleTypeElt (ArraySliceType::get (element.getType ()),
84+ element.getName ());
8785 break ;
8886 }
8987 case RegexCaptureStructureCode::FormOptional: {
90- auto &type = scopes.back ().back ();
91- type = OptionalType::get (type);
88+ auto &element = scopes.back ().back ();
89+ element = TupleTypeElt (OptionalType::get (element.getType ()),
90+ element.getName ());
9291 break ;
9392 }
9493 case RegexCaptureStructureCode::BeginTuple:
9594 scopes.push_back ({});
9695 break ;
9796 case RegexCaptureStructureCode::EndTuple: {
9897 auto children = scopes.pop_back_val ();
99- if (children.size () > ctx.getStringProcessingTupleDeclMaxArity ())
100- return true ;
101- auto tupleDecl = ctx.getStringProcessingTupleDecl (children.size ());
102- auto type = BoundGenericStructType::get (tupleDecl, Type (), children);
98+ auto type = TupleType::get (children, ctx);
10399 scopes.back ().push_back (type);
104100 break ;
105101 }
0 commit comments