aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliu fengyun <liu@fengy.me>2016-12-08 21:15:34 +0100
committerliu fengyun <liu@fengy.me>2016-12-08 22:11:38 +0100
commitd14de3d7b5955d353ba3108b91ad4eadc6697908 (patch)
tree44bb717e7e45095d959840fdc055b8d584a685b4
parentac160ea20dc3a18cad33484286cb3e37e9fe1171 (diff)
downloaddotty-d14de3d7b5955d353ba3108b91ad4eadc6697908.tar.gz
dotty-d14de3d7b5955d353ba3108b91ad4eadc6697908.tar.bz2
dotty-d14de3d7b5955d353ba3108b91ad4eadc6697908.zip
fix #1779: support $_ and $_id in interpolated string
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Parsers.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Scanners.scala2
-rw-r--r--tests/run/i1779.check1
-rw-r--r--tests/run/i1779.scala13
4 files changed, 19 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index 51dafc928..1f5ad397d 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -625,6 +625,10 @@ object Parsers {
atPos(in.offset) {
if (in.token == IDENTIFIER)
termIdent()
+ else if (in.token == USCORE) {
+ in.nextToken()
+ Ident(nme.WILDCARD)
+ }
else if (in.token == THIS) {
in.nextToken()
This(EmptyTypeIdent)
diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
index 60003d098..101be167e 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
@@ -758,7 +758,7 @@ object Scanners {
finishStringPart()
nextRawChar()
next.token = LBRACE
- } else if (Character.isUnicodeIdentifierStart(ch)) {
+ } else if (Character.isUnicodeIdentifierStart(ch) || ch == '_') {
finishStringPart()
do {
putChar(ch)
diff --git a/tests/run/i1779.check b/tests/run/i1779.check
new file mode 100644
index 000000000..4ef6e900e
--- /dev/null
+++ b/tests/run/i1779.check
@@ -0,0 +1 @@
+ extends
diff --git a/tests/run/i1779.scala b/tests/run/i1779.scala
new file mode 100644
index 000000000..e81bc97b6
--- /dev/null
+++ b/tests/run/i1779.scala
@@ -0,0 +1,13 @@
+object Test {
+ implicit class Foo(sc: StringContext) {
+ object q {
+ def unapply(arg: Any): Option[(Any, Any)] =
+ Some((sc.parts(0), sc.parts(1)))
+ }
+ }
+
+ def main(args: Array[String]): Unit = {
+ val q"class $_ extends $_parent" = new Object
+ println(_parent)
+ }
+}