@@ -188,7 +188,7 @@ object SourceCode {
188
188
case Select (newTree : New , _) =>
189
189
printType(newTree.tpe)(using Some (cdef.symbol))
190
190
case parent : Term =>
191
- throw new MatchError (parent.show(using Printer .TreeStructure ))
191
+ cannotBeShownAsSource (parent.show(using Printer .TreeStructure ))
192
192
}
193
193
194
194
def printSeparated (list : List [Tree /* Term | TypeTree */ ]): Unit = list match {
@@ -536,7 +536,7 @@ object SourceCode {
536
536
printCaseDef(tree)
537
537
538
538
case _ =>
539
- throw new MatchError (tree.show(using Printer .TreeStructure ))
539
+ cannotBeShownAsSource (tree.show(using Printer .TreeStructure ))
540
540
541
541
}
542
542
@@ -934,7 +934,7 @@ object SourceCode {
934
934
case Ident (" unapply" | " unapplySeq" ) =>
935
935
this += fun.symbol.owner.fullName.stripSuffix(" $" )
936
936
case _ =>
937
- throw new MatchError (fun.show(using Printer .TreeStructure ))
937
+ cannotBeShownAsSource (fun.show(using Printer .TreeStructure ))
938
938
}
939
939
inParens(printPatterns(patterns, " , " ))
940
940
@@ -953,7 +953,7 @@ object SourceCode {
953
953
printTree(v)
954
954
955
955
case _ =>
956
- throw new MatchError (pattern.show(using Printer .TreeStructure ))
956
+ cannotBeShownAsSource (pattern.show(using Printer .TreeStructure ))
957
957
958
958
}
959
959
@@ -1079,7 +1079,7 @@ object SourceCode {
1079
1079
printTypeTree(tpt)
1080
1080
1081
1081
case _ =>
1082
- throw new MatchError (tree.show(using Printer .TreeStructure ))
1082
+ cannotBeShownAsSource (tree.show(using Printer .TreeStructure ))
1083
1083
1084
1084
}
1085
1085
@@ -1248,7 +1248,7 @@ object SourceCode {
1248
1248
printType(rhs)
1249
1249
1250
1250
case _ =>
1251
- throw new MatchError (tpe.show(using Printer .TypeReprStructure ))
1251
+ cannotBeShownAsSource (tpe.show(using Printer .TypeReprStructure ))
1252
1252
}
1253
1253
1254
1254
private def printSelector (sel : Selector ): this .type = sel match {
@@ -1287,7 +1287,7 @@ object SourceCode {
1287
1287
val sym = annot.tpe.typeSymbol
1288
1288
sym != Symbol .requiredClass(" scala.forceInline" ) &&
1289
1289
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 ))
1291
1291
}
1292
1292
printAnnotations(annots)
1293
1293
if (annots.nonEmpty) this += " "
@@ -1462,6 +1462,9 @@ object SourceCode {
1462
1462
}
1463
1463
}
1464
1464
1465
+ private def cannotBeShownAsSource (x : String ): Nothing =
1466
+ throw new Exception (s " $x does not have a source representation " )
1467
+
1465
1468
private object SpecialOp {
1466
1469
def unapply (arg : Tree ): Option [(String , List [Term ])] = arg match {
1467
1470
case arg @ Apply (fn, args) =>
0 commit comments