@@ -188,7 +188,7 @@ object SourceCode {
188188 case Select (newTree : New , _) =>
189189 printType(newTree.tpe)(using Some (cdef.symbol))
190190 case parent : Term =>
191- throw new MatchError (parent.show(using Printer .TreeStructure ))
191+ cannotBeShownAsSource (parent.show(using Printer .TreeStructure ))
192192 }
193193
194194 def printSeparated (list : List [Tree /* Term | TypeTree */ ]): Unit = list match {
@@ -536,7 +536,7 @@ object SourceCode {
536536 printCaseDef(tree)
537537
538538 case _ =>
539- throw new MatchError (tree.show(using Printer .TreeStructure ))
539+ cannotBeShownAsSource (tree.show(using Printer .TreeStructure ))
540540
541541 }
542542
@@ -934,7 +934,7 @@ object SourceCode {
934934 case Ident (" unapply" | " unapplySeq" ) =>
935935 this += fun.symbol.owner.fullName.stripSuffix(" $" )
936936 case _ =>
937- throw new MatchError (fun.show(using Printer .TreeStructure ))
937+ cannotBeShownAsSource (fun.show(using Printer .TreeStructure ))
938938 }
939939 inParens(printPatterns(patterns, " , " ))
940940
@@ -953,7 +953,7 @@ object SourceCode {
953953 printTree(v)
954954
955955 case _ =>
956- throw new MatchError (pattern.show(using Printer .TreeStructure ))
956+ cannotBeShownAsSource (pattern.show(using Printer .TreeStructure ))
957957
958958 }
959959
@@ -1079,7 +1079,7 @@ object SourceCode {
10791079 printTypeTree(tpt)
10801080
10811081 case _ =>
1082- throw new MatchError (tree.show(using Printer .TreeStructure ))
1082+ cannotBeShownAsSource (tree.show(using Printer .TreeStructure ))
10831083
10841084 }
10851085
@@ -1248,7 +1248,7 @@ object SourceCode {
12481248 printType(rhs)
12491249
12501250 case _ =>
1251- throw new MatchError (tpe.show(using Printer .TypeReprStructure ))
1251+ cannotBeShownAsSource (tpe.show(using Printer .TypeReprStructure ))
12521252 }
12531253
12541254 private def printSelector (sel : Selector ): this .type = sel match {
@@ -1287,7 +1287,7 @@ object SourceCode {
12871287 val sym = annot.tpe.typeSymbol
12881288 sym != Symbol .requiredClass(" scala.forceInline" ) &&
12891289 sym.maybeOwner != Symbol .requiredPackage(" scala.annotation.internal" )
1290- case x => throw new MatchError (x.show(using Printer .TreeStructure ))
1290+ case x => cannotBeShownAsSource (x.show(using Printer .TreeStructure ))
12911291 }
12921292 printAnnotations(annots)
12931293 if (annots.nonEmpty) this += " "
@@ -1458,6 +1458,9 @@ object SourceCode {
14581458 }
14591459 }
14601460
1461+ private def cannotBeShownAsSource (x : String ): Nothing =
1462+ throw new Exception (s " $x does not have a source representation " )
1463+
14611464 private object SpecialOp {
14621465 def unapply (arg : Tree ): Option [(String , List [Term ])] = arg match {
14631466 case arg @ Apply (fn, args) =>
0 commit comments