diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 4c3819e9872c..2239a45096b8 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -846,6 +846,10 @@ trait Checking { case _ => EmptyTree if extractor.isEmpty then em"pattern binding uses refutable extractor" + else if extractor.symbol eq defn.QuoteMatching_ExprMatch then + em"pattern binding uses refutable extractor `'{...}`" + else if extractor.symbol eq defn.QuoteMatching_TypeMatch then + em"pattern binding uses refutable extractor `'[...]`" else em"pattern binding uses refutable extractor `$extractor`" diff --git a/tests/neg-custom-args/fatal-warnings/i16649-refutable.check b/tests/neg-custom-args/fatal-warnings/i16649-refutable.check new file mode 100644 index 000000000000..5b3d460c7f09 --- /dev/null +++ b/tests/neg-custom-args/fatal-warnings/i16649-refutable.check @@ -0,0 +1,8 @@ +-- Error: tests/neg-custom-args/fatal-warnings/i16649-refutable.scala:4:6 ---------------------------------------------- +4 | val '{ ($y: Int) + ($z: Int) } = x // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | pattern binding uses refutable extractor `'{...}` + | + | If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, + | which may result in a MatchError at runtime. + | This patch can be rewritten automatically under -rewrite -source 3.2-migration. diff --git a/tests/neg-custom-args/fatal-warnings/i16649-refutable.scala b/tests/neg-custom-args/fatal-warnings/i16649-refutable.scala new file mode 100644 index 000000000000..2a42f652e093 --- /dev/null +++ b/tests/neg-custom-args/fatal-warnings/i16649-refutable.scala @@ -0,0 +1,4 @@ +import quoted.* + +def foo(using Quotes)(x: Expr[Int]) = + val '{ ($y: Int) + ($z: Int) } = x // error