Skip to content

Commit 2b88a27

Browse files
committed
Improve match error on reflect trees
Print the tree extractors of the reflection API instead of the underlying case class toString.
1 parent 7208bd8 commit 2b88a27

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/src/scala/quoted/Quotes.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4621,6 +4621,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
46214621
case Bind(_, body) => foldTree(x, body)(owner)
46224622
case Unapply(fun, implicits, patterns) => foldTrees(foldTrees(foldTree(x, fun)(owner), implicits)(owner), patterns)(owner)
46234623
case Alternatives(patterns) => foldTrees(x, patterns)(owner)
4624+
case _ => throw MatchError(tree.show(using Printer.TreeStructure))
46244625
}
46254626
}
46264627
end TreeAccumulator
@@ -4685,6 +4686,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
46854686
Alternatives.copy(pattern)(transformTrees(pattern.patterns)(owner))
46864687
case TypedOrTest(inner, tpt) =>
46874688
TypedOrTest.copy(tree)(transformTree(inner)(owner), transformTypeTree(tpt)(owner))
4689+
case _ =>
4690+
throw MatchError(tree.show(using Printer.TreeStructure))
46884691
}
46894692
}
46904693

@@ -4713,6 +4716,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
47134716
Import.copy(tree)(transformTerm(tree.expr)(owner), tree.selectors)
47144717
case tree: Export =>
47154718
tree
4719+
case _ =>
4720+
throw MatchError(tree.show(using Printer.TreeStructure))
47164721
}
47174722
}
47184723

@@ -4758,6 +4763,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
47584763
Repeated.copy(tree)(transformTerms(elems)(owner), transformTypeTree(elemtpt)(owner))
47594764
case Inlined(call, bindings, expansion) =>
47604765
Inlined.copy(tree)(call, transformSubTrees(bindings)(owner), transformTerm(expansion)(owner))
4766+
case _ =>
4767+
throw MatchError(tree.show(using Printer.TreeStructure))
47614768
}
47624769
}
47634770

@@ -4786,6 +4793,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
47864793
TypeBind.copy(tree)(tree.name, tree.body)
47874794
case tree: TypeBlock =>
47884795
TypeBlock.copy(tree)(tree.aliases, tree.tpt)
4796+
case _ =>
4797+
throw MatchError(tree.show(using Printer.TreeStructure))
47894798
}
47904799

47914800
def transformCaseDef(tree: CaseDef)(owner: Symbol): CaseDef = {

0 commit comments

Comments
 (0)