Skip to content

Commit 0e6746d

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Fix printer for SplicePattern
[Cherry-picked 9d9bf61]
1 parent 0899b4b commit 0e6746d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
743743
val spliceTypeText = (keywordStr("[") ~ toTextGlobal(tree.typeOpt) ~ keywordStr("]")).provided(printDebug && tree.typeOpt.exists)
744744
keywordStr("$") ~ spliceTypeText ~ {
745745
if args.isEmpty then keywordStr("{") ~ inPattern(toText(pattern)) ~ keywordStr("}")
746-
else toText(pattern.symbol.name) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"
746+
else toText(pattern) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"
747747
}
748748
case Hole(isTerm, idx, args, content) =>
749749
val (prefix, postfix) = if isTerm then ("{{{", "}}}") else ("[[[", "]]]")

tests/neg-macros/i19342.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/neg-macros/i19342.scala:5:26 ---------------------------------------------------------------------------
2+
5 | case '{ ((y: Int) => $f(y)).apply($z: Int) } => () // error
3+
| ^
4+
| Type must be fully defined.
5+
| Consider annotating the splice using a type ascription:
6+
| ($f(y): XYZ).

tests/neg-macros/i19342.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted.*
2+
3+
def scrutinizeHoas(expr: Expr[Int])(using Quotes): Unit =
4+
expr match {
5+
case '{ ((y: Int) => $f(y)).apply($z: Int) } => () // error
6+
case _ => ()
7+
}

0 commit comments

Comments
 (0)