diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-11-16 21:58:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-16 21:58:02 +0100 |
commit | 55cff2cfa3f615f9eac158b1d2394ebbf473c6fb (patch) | |
tree | 651990bd0c117065edb6ab20cef5c4ffc4ddc408 /src | |
parent | 06b2b382a80fd4a53c3e6cf7119822319b87e3df (diff) | |
parent | 3dfcb1577d87ed817da0a1445ba414b2ec4c616d (diff) | |
download | scala-55cff2cfa3f615f9eac158b1d2394ebbf473c6fb.tar.gz scala-55cff2cfa3f615f9eac158b1d2394ebbf473c6fb.tar.bz2 scala-55cff2cfa3f615f9eac158b1d2394ebbf473c6fb.zip |
Merge pull request #5440 from som-snytt/issue/9944
SI-9944 Scan after interp expr keeps CR
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 3a659fd0f0..a8cc7f91c2 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -261,6 +261,14 @@ trait Scanners extends ScannersCommon { private def inMultiLineInterpolation = inStringInterpolation && sepRegions.tail.nonEmpty && sepRegions.tail.head == STRINGPART + /** Are we in a `${ }` block? such that RBRACE exits back into multiline string. */ + private def inMultiLineInterpolatedExpression = { + sepRegions match { + case RBRACE :: STRINGLIT :: STRINGPART :: rest => true + case _ => false + } + } + /** read next token and return last offset */ def skipToken(): Offset = { @@ -327,7 +335,7 @@ trait Scanners extends ScannersCommon { lastOffset -= 1 } if (inStringInterpolation) fetchStringPart() else fetchToken() - if(token == ERROR) { + if (token == ERROR) { if (inMultiLineInterpolation) sepRegions = sepRegions.tail.tail else if (inStringInterpolation) @@ -562,7 +570,8 @@ trait Scanners extends ScannersCommon { case ')' => nextChar(); token = RPAREN case '}' => - nextChar(); token = RBRACE + if (inMultiLineInterpolatedExpression) nextRawChar() else nextChar() + token = RBRACE case '[' => nextChar(); token = LBRACKET case ']' => |