From dbb08488fb3e843e2ffba019494b6d1939ffe26a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 9 Aug 2022 11:33:27 +0200 Subject: [PATCH] Fix quoted pattens with references to private fields Reverts 0b072d6b7df6d9c65d6ffce779c3417df42b47bd Fixes #15676 --- .../dotty/tools/dotc/typer/QuotesAndSplices.scala | 2 +- tests/pos-macros/i15676/Macro_1.scala | 14 ++++++++++++++ tests/pos-macros/i15676/Test_2.scala | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/pos-macros/i15676/Macro_1.scala create mode 100644 tests/pos-macros/i15676/Test_2.scala diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index fa29f450be2a..2033c4588639 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -49,7 +49,7 @@ trait QuotesAndSplices { report.error(em"Quotes require stable Quotes, but found non stable $qctx", qctx.srcPos) if ctx.mode.is(Mode.Pattern) then - typedQuotePattern(tree, pt, qctx).withSpan(tree.span) + makeInlineable(typedQuotePattern(tree, pt, qctx).withSpan(tree.span)) else if tree.quoted.isType then val msg = em"""Quoted types `'[..]` can only be used in patterns. | diff --git a/tests/pos-macros/i15676/Macro_1.scala b/tests/pos-macros/i15676/Macro_1.scala new file mode 100644 index 000000000000..361adaaa340b --- /dev/null +++ b/tests/pos-macros/i15676/Macro_1.scala @@ -0,0 +1,14 @@ +package foo + +import scala.quoted.* + +private[foo] object Foo: + def apply(): Int = ??? + +inline def test(): Unit = ${ testExpr() } + +private def testExpr()(using Quotes): Expr[Unit] = { + '{ Foo() } match + case '{ Foo() } => + '{} +} diff --git a/tests/pos-macros/i15676/Test_2.scala b/tests/pos-macros/i15676/Test_2.scala new file mode 100644 index 000000000000..9e45846ff8dc --- /dev/null +++ b/tests/pos-macros/i15676/Test_2.scala @@ -0,0 +1 @@ +def Test() = foo.test()