From 74cee6abb41bf84bd5c037a64ad96d9987746703 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Sun, 27 Nov 2016 20:57:43 +0100 Subject: [PATCH 1/2] fix #1748: desugaring with StringContext in PatDef --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 ++ tests/pos/i1784.scala | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/pos/i1784.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 4b2ff1bc313f..c8b1ed909967 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1079,6 +1079,8 @@ object desugar { collect(tree) case Tuple(trees) => trees foreach collect + case Thicket(trees) => + trees foreach collect case _ => } collect(tree) diff --git a/tests/pos/i1784.scala b/tests/pos/i1784.scala new file mode 100644 index 000000000000..9bd487caa062 --- /dev/null +++ b/tests/pos/i1784.scala @@ -0,0 +1,14 @@ +object Test { + implicit class Foo(sc: StringContext) { + object q { + def unapply(args: Any*): Option[(Any, Any)] = + Some((sc.parts(0), sc.parts(1))) + } + } + + def f(defn: Any): Any = { + val q"class $name extends $parent" = defn + println(name) + println(parent) + } +} \ No newline at end of file From 8f3301e48ed82dbfc316082d293849a45e187d13 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Mon, 28 Nov 2016 09:43:03 +0100 Subject: [PATCH 2/2] make test runnable --- tests/run/i1748.check | 2 ++ tests/{pos/i1784.scala => run/i1748.scala} | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 tests/run/i1748.check rename tests/{pos/i1784.scala => run/i1748.scala} (53%) diff --git a/tests/run/i1748.check b/tests/run/i1748.check new file mode 100644 index 000000000000..888299747af9 --- /dev/null +++ b/tests/run/i1748.check @@ -0,0 +1,2 @@ +class + extends diff --git a/tests/pos/i1784.scala b/tests/run/i1748.scala similarity index 53% rename from tests/pos/i1784.scala rename to tests/run/i1748.scala index 9bd487caa062..bb3df1336563 100644 --- a/tests/pos/i1784.scala +++ b/tests/run/i1748.scala @@ -1,13 +1,13 @@ object Test { implicit class Foo(sc: StringContext) { object q { - def unapply(args: Any*): Option[(Any, Any)] = + def unapply(arg: Any): Option[(Any, Any)] = Some((sc.parts(0), sc.parts(1))) } } - def f(defn: Any): Any = { - val q"class $name extends $parent" = defn + def main(args: Array[String]): Unit = { + val q"class $name extends $parent" = new Object println(name) println(parent) }