Skip to content

Commit acc9423

Browse files
committed
Fix pattern decompiler
Now we can have patterns that do not have a full tree (i.e. just an Ident to the `unapply`)
1 parent 6f9ae87 commit acc9423

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,17 @@ trait Printers
13101310
printPattern(pattern)
13111311

13121312
case Pattern.Unapply(fun, implicits, patterns) =>
1313-
fun match {
1314-
case Term.Select(extractor, "unapply" | "unapplySeq") => printTree(extractor)
1315-
case Term.TypeApply(Term.Select(extractor, "unapply" | "unapplySeq"), _) => printTree(extractor)
1316-
case _ => throw new MatchError(fun.show)
1313+
val fun2 = fun match {
1314+
case Term.TypeApply(fun2, _) => fun2
1315+
case _ => fun
1316+
}
1317+
fun2 match {
1318+
case Term.Select(extractor, "unapply" | "unapplySeq") =>
1319+
printTree(extractor)
1320+
case Term.Ident("unapply" | "unapplySeq") =>
1321+
this += fun.symbol.owner.fullName.stripSuffix("$")
1322+
case _ =>
1323+
throw new MatchError(fun.show)
13171324
}
13181325
inParens(printPatterns(patterns, ", "))
13191326

0 commit comments

Comments
 (0)