File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
src/compiler/scala/tools/nsc/ast/parser Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,14 @@ trait Scanners extends ScannersCommon {
246
246
private def inMultiLineInterpolation =
247
247
inStringInterpolation && sepRegions.tail.nonEmpty && sepRegions.tail.head == STRINGPART
248
248
249
+ /** Are we in a `${ }` block? such that RBRACE exits back into multiline string. */
250
+ private def inMultiLineInterpolatedExpression = {
251
+ sepRegions match {
252
+ case RBRACE :: STRINGLIT :: STRINGPART :: rest => true
253
+ case _ => false
254
+ }
255
+ }
256
+
249
257
/** read next token and return last offset
250
258
*/
251
259
def skipToken (): Offset = {
@@ -312,7 +320,7 @@ trait Scanners extends ScannersCommon {
312
320
lastOffset -= 1
313
321
}
314
322
if (inStringInterpolation) fetchStringPart() else fetchToken()
315
- if (token == ERROR ) {
323
+ if (token == ERROR ) {
316
324
if (inMultiLineInterpolation)
317
325
sepRegions = sepRegions.tail.tail
318
326
else if (inStringInterpolation)
@@ -547,7 +555,8 @@ trait Scanners extends ScannersCommon {
547
555
case ')' =>
548
556
nextChar(); token = RPAREN
549
557
case '}' =>
550
- nextChar(); token = RBRACE
558
+ if (inMultiLineInterpolatedExpression) nextRawChar() else nextChar()
559
+ token = RBRACE
551
560
case '[' =>
552
561
nextChar(); token = LBRACKET
553
562
case ']' =>
Original file line number Diff line number Diff line change
1
+ [[syntax trees at end of parser]] // newSource1.scala
2
+ package <empty> {
3
+ class C extends scala.AnyRef {
4
+ def <init>() = {
5
+ super.<init>();
6
+ ()
7
+ };
8
+ def g = 42;
9
+ def f = StringContext("123\r\n", "\r\n123\r\n").s(g)
10
+ }
11
+ }
12
+
Original file line number Diff line number Diff line change
1
+
2
+ import scala .tools .partest .ParserTest
3
+
4
+ object Test extends ParserTest {
5
+
6
+ def code = s """ class C { def g = 42 ; def f = s""\"123\r\n $$ { g }\r\n123\r\n""\"} """
7
+ }
You can’t perform that action at this time.
0 commit comments