@@ -1888,30 +1888,12 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1888
1888
TokReceiver->registerTokenKindChange (Tok.getLoc (),
1889
1889
tok::string_interpolation_anchor);
1890
1890
1891
- SourceLoc lParen, rParen;
1892
- SmallVector<Expr *, 4 > args;
1893
- SmallVector<Identifier, 4 > argLabels;
1894
- SmallVector<SourceLoc, 4 > argLabelLocs;
1895
- Expr *trailingClosureNeverPresent;
1896
- ParserStatus S =
1897
- parseExprList (tok::l_paren, tok::r_paren,
1898
- /* isPostfix=*/ false , /* isExprBasic=*/ true ,
1899
- lParen, args, argLabels, argLabelLocs, rParen,
1900
- trailingClosureNeverPresent,
1901
- SyntaxKind::FunctionCallArgumentList);
1902
- assert (!trailingClosureNeverPresent);
1903
-
1904
- Status |= S;
1905
- // If there was an error parsing a parameter, add an ErrorExpr to
1906
- // represent it. Prevents spurious errors about a nonexistent
1907
- // appendInterpolation() overload.
1908
- if (S.isError () && args.size () == 0 )
1909
- args.push_back (new (Context) ErrorExpr (SourceRange (lParen, rParen)));
1910
-
1911
- while (argLabels.size () < args.size ())
1912
- argLabels.push_back (Identifier ());
1913
- while (argLabelLocs.size () < args.size ())
1914
- argLabelLocs.push_back (SourceLoc ());
1891
+ auto callee = new (Context) UnresolvedDotExpr (InterpolationVarRef,
1892
+ /* dotloc=*/ SourceLoc (),
1893
+ appendInterpolation,
1894
+ /* nameloc=*/ DeclNameLoc (),
1895
+ /* Implicit=*/ true );
1896
+ auto S = parseExprCallSuffix (makeParserResult (callee), true );
1915
1897
1916
1898
// If we stopped parsing the expression before the expression segment is
1917
1899
// over, eat the remaining tokens into a token list
@@ -1925,20 +1907,14 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1925
1907
L->getLocForEndOfToken (SourceMgr, Tok.getLoc ()));
1926
1908
}
1927
1909
1910
+ Expr *call = S.getPtrOrNull ();
1911
+ if (!call)
1912
+ call = new (Context) ErrorExpr (SourceRange (Segment.Loc ,
1913
+ Segment.getEndLoc ()));
1914
+
1928
1915
InterpolationCount += 1 ;
1929
-
1930
- auto AppendInterpolationRef =
1931
- new (Context) UnresolvedDotExpr (InterpolationVarRef,
1932
- /* dotloc=*/ SourceLoc (),
1933
- appendInterpolation,
1934
- /* nameloc=*/ DeclNameLoc (),
1935
- /* Implicit=*/ true );
1936
- auto AppendInterpolationCall =
1937
- CallExpr::create (Context, AppendInterpolationRef,
1938
- lParen, args, argLabels, argLabelLocs, rParen,
1939
- /* trailingClosure=*/ nullptr , /* implicit=*/ false );
1940
-
1941
- Stmts.push_back (AppendInterpolationCall);
1916
+ Stmts.push_back (call);
1917
+ Status |= S;
1942
1918
1943
1919
if (!Tok.is (tok::eof)) {
1944
1920
diagnose (Tok, diag::string_interpolation_extra);
0 commit comments