@@ -340,22 +340,6 @@ extension Parser {
340340 unexpectedBeforeClosingQuote: [ RawTokenSyntax ] ,
341341 closingQuote: RawTokenSyntax
342342 ) {
343- // -------------------------------------------------------------------------
344- // Precondition
345-
346- precondition (
347- allSegments. allSatisfy {
348- if case . stringSegment( let segment) = $0 {
349- return segment. unexpectedBeforeContent == nil
350- && segment. unexpectedAfterContent == nil
351- && segment. content. leadingTriviaByteLength == 0
352- } else {
353- return true
354- }
355- } ,
356- " String segment produced by the lexer should not have unexpected text or trivia because we would drop it during post-processing "
357- )
358-
359343 // -------------------------------------------------------------------------
360344 // Variables
361345
@@ -395,6 +379,9 @@ extension Parser {
395379 // Parse indentation of the closing quote
396380
397381 if let lastSegment,
382+ lastSegment. unexpectedBeforeContent == nil ,
383+ lastSegment. unexpectedAfterContent == nil ,
384+ lastSegment. content. leadingTriviaByteLength == 0 ,
398385 let parsedTrivia = parseIndentationTrivia ( text: lastSegment. content. tokenText)
399386 {
400387 indentationTrivia = parsedTrivia
@@ -409,10 +396,9 @@ extension Parser {
409396 arena: self . arena
410397 )
411398 } else {
412- if let lastSegment = lastSegment {
413- indentationTrivia = TriviaParser . parseTrivia ( lastSegment. content. tokenText, position: . leading) . prefix ( while: {
414- $0. isIndentationWhitespace
415- } )
399+ if let lastSegment {
400+ indentationTrivia = TriviaParser . parseTrivia ( lastSegment. content. tokenText, position: . leading)
401+ . prefix ( while: \. isIndentationWhitespace)
416402 let indentationByteLength = indentationTrivia. reduce ( 0 , { $0 + $1. byteLength } )
417403 indentation = SyntaxText ( rebasing: lastSegment. content. tokenText [ 0 ..< indentationByteLength] )
418404 middleSegments. append ( . stringSegment( lastSegment) )
@@ -703,10 +689,7 @@ extension Parser {
703689 }
704690 }
705691
706- let ( unexpectedBetweenSegmentAndCloseQuote, closeQuote) = self . expect (
707- anyIn: SimpleStringLiteralExprSyntax . ClosingQuoteOptions. self,
708- default: openQuote. closeTokenKind
709- )
692+ let ( unexpectedBetweenSegmentAndCloseQuote, closeQuote) = self . expect ( openQuote. closeTokenKind. spec)
710693 let closeDelimiter = self . consume ( if: . rawStringPoundDelimiter)
711694
712695 if openQuote. tokenKind == . multilineStringQuote, !openQuote. isMissing, !closeQuote. isMissing {
0 commit comments