From 16d2a4f49fcda67b9e307ff1fcd51d884c8f7db5 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sun, 29 Apr 2018 16:03:34 +0200 Subject: [PATCH] Fix #4396: Check level of owners of type parameters Fixes buggy condition inserted in #4363 --- compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala | 2 +- tests/pos/i4396a.scala | 3 +++ tests/pos/i4396b.scala | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i4396a.scala create mode 100644 tests/pos/i4396b.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 479e3e0fad5e..ae9d63c3c222 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -245,7 +245,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer { l == level || sym.is(Inline) && sym.owner.is(Macro) && sym.info.isValueType && l - 1 == level case None => - level == 0 + !sym.is(Param) || levelOK(sym.owner) } /** Issue a "splice outside quote" error unless we ar in the body of an inline method */ diff --git a/tests/pos/i4396a.scala b/tests/pos/i4396a.scala new file mode 100644 index 000000000000..0a69f685f986 --- /dev/null +++ b/tests/pos/i4396a.scala @@ -0,0 +1,3 @@ +class Test { + '(Option(4) match { case Some(a) => a; case None => 1 }) +} \ No newline at end of file diff --git a/tests/pos/i4396b.scala b/tests/pos/i4396b.scala new file mode 100644 index 000000000000..ec327cfa61c1 --- /dev/null +++ b/tests/pos/i4396b.scala @@ -0,0 +1,3 @@ +class Test { + '{ case class Foo() } +} \ No newline at end of file