summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala22
-rw-r--r--test/files/run/bug2514.scala15
2 files changed, 30 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index c966a23fcb..150de8db4d 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -306,13 +306,7 @@ trait Scanners {
base = 10
getNumber()
case '`' =>
- nextChar()
- if (getStringLit('`')) {
- finishNamed();
- if (name.length == 0) syntaxError("empty quoted identifier")
- token = BACKQUOTED_IDENT
- }
- else syntaxError("unclosed quoted identifier")
+ getBackquotedIdent()
case '\"' =>
nextChar()
if (ch == '\"') {
@@ -475,6 +469,16 @@ trait Scanners {
// Identifiers ---------------------------------------------------------------
+ private def getBackquotedIdent(): Unit = {
+ nextChar()
+ if (getStringLit('`')) {
+ finishNamed();
+ if (name.length == 0) syntaxError("empty quoted identifier")
+ token = BACKQUOTED_IDENT
+ }
+ else syntaxError("unclosed quoted identifier")
+ }
+
private def getIdentRest(): Unit = (ch: @switch) match {
case 'A' | 'B' | 'C' | 'D' | 'E' |
'F' | 'G' | 'H' | 'I' | 'J' |
@@ -747,6 +751,10 @@ trait Scanners {
case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' =>
return restOfNumber()
+ /** Backquoted idents like 22.`foo` */
+ case '`' =>
+ return setStrVal()
+
/** These letters may be part of a literal, or a method invocation on an Int */
case 'd' | 'D' | 'f' | 'F' =>
lookahead.nextChar()
diff --git a/test/files/run/bug2514.scala b/test/files/run/bug2514.scala
new file mode 100644
index 0000000000..e23b441ecf
--- /dev/null
+++ b/test/files/run/bug2514.scala
@@ -0,0 +1,15 @@
+object Test
+{
+ implicit def x[A](a: A) = new { def xx = a }
+
+ def main(args: Array[String]): Unit = {
+ val r1 = 12 xx;
+ val r2 = 12.xx
+ val r3 = 12.`xx`
+ val r4 = 12.xx + 12.xx
+ val r5 = 12.`xx` + 12.xx
+ val r6 = 12.3.`xx` + 12.xx
+
+ assert(r5 == 24)
+ }
+} \ No newline at end of file