diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index b0c5a4bf0698..3478b493caeb 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -43,7 +43,7 @@ trait QuotesAndSplices { def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree = { record("typedQuote") tree.quoted match { - case untpd.Splice(innerExpr) if tree.isTerm => + case untpd.Splice(innerExpr) if tree.isTerm && !ctx.mode.is(Mode.Pattern) => report.warning("Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.", tree.srcPos) case untpd.TypSplice(innerType) if tree.isType => report.warning("Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ.", tree.srcPos) diff --git a/tests/pos-special/fatal-warnings/i9804.scala b/tests/pos-special/fatal-warnings/i9804.scala new file mode 100644 index 000000000000..8aa4c34eca31 --- /dev/null +++ b/tests/pos-special/fatal-warnings/i9804.scala @@ -0,0 +1,5 @@ +import scala.quoted._ + +def f[A: Type](e: Expr[A])(using Quotes): Expr[A] = e match { + case '{ $e2 } => e2 +}