@@ -1134,11 +1134,12 @@ trait Printers extends api.Printers { self: SymbolTable =>
11341134 def newRawTreePrinter (writer : PrintWriter ): RawTreePrinter = new RawTreePrinter (writer)
11351135
11361136 // provides footnotes for types and mirrors
1137- import scala . collection . mutable .{ Map , WeakHashMap , SortedSet }
1138- private val footnoteIndex = new FootnoteIndex
1139- private class FootnoteIndex {
1137+ private class Footnotes {
1138+ import scala . collection . mutable .{ Map , WeakHashMap , SortedSet }
1139+
11401140 private val index = Map [Class [_], WeakHashMap [Any , Int ]]()
11411141 private def classIndex [T : ClassTag ] = index.getOrElseUpdate(classTag[T ].runtimeClass, WeakHashMap [Any , Int ]())
1142+
11421143 private val counters = Map [Class [_], Int ]()
11431144 private def nextCounter [T : ClassTag ] = {
11441145 val clazz = classTag[T ].runtimeClass
@@ -1147,29 +1148,26 @@ trait Printers extends api.Printers { self: SymbolTable =>
11471148 counters(clazz)
11481149 }
11491150
1150- def mkFootnotes () = new Footnotes
1151- class Footnotes {
1152- private val footnotes = Map [Class [_], SortedSet [Int ]]()
1153- private def classFootnotes [T : ClassTag ] = footnotes.getOrElseUpdate(classTag[T ].runtimeClass, SortedSet [Int ]())
1151+ private val footnotes = Map [Class [_], SortedSet [Int ]]()
1152+ private def classFootnotes [T : ClassTag ] = footnotes.getOrElseUpdate(classTag[T ].runtimeClass, SortedSet [Int ]())
11541153
1155- def put [T : ClassTag ](any : T ): Int = {
1156- val index = classIndex[T ].getOrElseUpdate(any, nextCounter[T ])
1157- classFootnotes[T ] += index
1158- index
1159- }
1154+ def put [T : ClassTag ](any : T ): Int = {
1155+ val index = classIndex[T ].getOrElseUpdate(any, nextCounter[T ])
1156+ classFootnotes[T ] += index
1157+ index
1158+ }
11601159
1161- def get [T : ClassTag ]: List [(Int , Any )] =
1162- classFootnotes[T ].toList map (fi => (fi, classIndex[T ].find{ case (any, ii) => ii == fi }.get._1))
1163-
1164- def print [T : ClassTag ](printer : Printers .super .TreePrinter ): Unit = {
1165- val footnotes = get[T ]
1166- if (footnotes.nonEmpty) {
1167- printer.print(EOL )
1168- footnotes.zipWithIndex foreach {
1169- case ((fi, any), ii) =>
1170- printer.print(" [" , fi, " ] " , any)
1171- if (ii < footnotes.length - 1 ) printer.print(EOL )
1172- }
1160+ def get [T : ClassTag ]: List [(Int , Any )] =
1161+ classFootnotes[T ].toList map (fi => (fi, classIndex[T ].find{ case (any, ii) => ii == fi }.get._1))
1162+
1163+ def print [T : ClassTag ](printer : Printers .super .TreePrinter ): Unit = {
1164+ val footnotes = get[T ]
1165+ if (footnotes.nonEmpty) {
1166+ printer.print(EOL )
1167+ footnotes.zipWithIndex foreach {
1168+ case ((fi, any), ii) =>
1169+ printer.print(" [" , fi, " ] " , any)
1170+ if (ii < footnotes.length - 1 ) printer.print(EOL )
11731171 }
11741172 }
11751173 }
@@ -1180,7 +1178,7 @@ trait Printers extends api.Printers { self: SymbolTable =>
11801178 private var depth = 0
11811179 private var printTypesInFootnotes = true
11821180 private var printingFootnotes = false
1183- private val footnotes = footnoteIndex.mkFootnotes ()
1181+ private val footnotes = new Footnotes ()
11841182
11851183 def print (args : Any * ): Unit = {
11861184 // don't print type footnotes if the argument is a mere type
0 commit comments