Skip to content

Commit 234cb00

Browse files
Merge pull request #11001 from dotty-staging/fix-#9804
Do not warn on canceled splices in quoted patterns
2 parents 4c2cddf + da38244 commit 234cb00

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait QuotesAndSplices {
4343
def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree = {
4444
record("typedQuote")
4545
tree.quoted match {
46-
case untpd.Splice(innerExpr) if tree.isTerm =>
46+
case untpd.Splice(innerExpr) if tree.isTerm && !ctx.mode.is(Mode.Pattern) =>
4747
report.warning("Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.", tree.srcPos)
4848
case untpd.TypSplice(innerType) if tree.isType =>
4949
report.warning("Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ.", tree.srcPos)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
def f[A: Type](e: Expr[A])(using Quotes): Expr[A] = e match {
4+
case '{ $e2 } => e2
5+
}

0 commit comments

Comments
 (0)