summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala27
-rw-r--r--test/files/run/t5530.check2
-rw-r--r--test/files/run/t5530.flags1
-rw-r--r--test/files/run/t5530.scala4
-rw-r--r--test/files/run/t5532.flags1
-rw-r--r--test/files/run/t5532.scala4
6 files changed, 30 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 2626ca26a6..2895d02dfe 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -670,12 +670,18 @@ trait Scanners extends ScannersCommon {
next.offset = charOffset - 1
}
if (ch == '"') {
- nextRawChar()
- if (!multiLine || isTripleQuote()) {
+ if (multiLine) {
+ nextRawChar()
+ if (isTripleQuote()) {
+ setStrVal()
+ token = STRINGLIT
+ } else
+ getStringPart(multiLine)
+ } else {
+ nextChar()
setStrVal()
token = STRINGLIT
- } else
- getStringPart(multiLine)
+ }
} else if (ch == '$') {
nextRawChar()
if (ch == '$') {
@@ -698,12 +704,15 @@ trait Scanners extends ScannersCommon {
} else {
syntaxError("invalid string interpolation")
}
- } else if ((ch == CR || ch == LF || ch == SU) && !isUnicodeEscape) {
- syntaxError("unclosed string literal")
} else {
- putChar(ch)
- nextRawChar()
- getStringPart(multiLine)
+ val isUnclosedLiteral = !isUnicodeEscape && (ch == SU || (!multiLine && (ch == CR || ch == LF)))
+ if (isUnclosedLiteral) {
+ syntaxError(if (!multiLine) "unclosed string literal" else "unclosed multi-line string literal")
+ } else {
+ putChar(ch)
+ nextRawChar()
+ getStringPart(multiLine)
+ }
}
}
diff --git a/test/files/run/t5530.check b/test/files/run/t5530.check
new file mode 100644
index 0000000000..1013e3356f
--- /dev/null
+++ b/test/files/run/t5530.check
@@ -0,0 +1,2 @@
+something like this
+ 7 now works!.
diff --git a/test/files/run/t5530.flags b/test/files/run/t5530.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/run/t5530.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/run/t5530.scala b/test/files/run/t5530.scala
new file mode 100644
index 0000000000..c8109a4004
--- /dev/null
+++ b/test/files/run/t5530.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ println(s"""something like this
+ ${3+4} now works!.""")
+} \ No newline at end of file
diff --git a/test/files/run/t5532.flags b/test/files/run/t5532.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/run/t5532.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/run/t5532.scala b/test/files/run/t5532.scala
new file mode 100644
index 0000000000..75004730bf
--- /dev/null
+++ b/test/files/run/t5532.scala
@@ -0,0 +1,4 @@
+object Test extends App {
+ val x = s"1"
+ val y = s"2"
+} \ No newline at end of file