Skip to content

Commit 65c1ae5

Browse files
committed
Adds debug logging for synthetic registration.
Investigatory tools for SI-5877
1 parent fd57069 commit 65c1ae5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/compiler/scala/tools/nsc/CompilationUnits.scala

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait CompilationUnits { self: Global =>
2323
/** One unit of compilation that has been submitted to the compiler.
2424
* It typically corresponds to a single file of source code. It includes
2525
* error-reporting hooks. */
26-
class CompilationUnit(val source: SourceFile) extends CompilationUnitContextApi {
26+
class CompilationUnit(val source: SourceFile) extends CompilationUnitContextApi { self =>
2727

2828
/** the fresh name creator */
2929
var fresh: FreshNameCreator = new FreshNameCreator.Default
@@ -57,7 +57,23 @@ trait CompilationUnits { self: Global =>
5757

5858
/** Synthetic definitions generated by namer, eliminated by typer.
5959
*/
60-
val synthetics = mutable.HashMap[Symbol, Tree]()
60+
object synthetics {
61+
private val map = mutable.HashMap[Symbol, Tree]()
62+
def update(sym: Symbol, tree: Tree) {
63+
debuglog(s"adding synthetic ($sym, $tree) to $self")
64+
map.update(sym, tree)
65+
}
66+
def -=(sym: Symbol) {
67+
debuglog(s"removing synthetic $sym from $self")
68+
map -= sym
69+
}
70+
def get(sym: Symbol): Option[Tree] = logResultIf[Option[Tree]](s"found synthetic for $sym in $self", _.isDefined) {
71+
map get sym
72+
}
73+
def keys: Iterable[Symbol] = map.keys
74+
def clear(): Unit = map.clear()
75+
override def toString = map.toString
76+
}
6177

6278
/** things to check at end of compilation unit */
6379
val toCheck = new ListBuffer[() => Unit]

0 commit comments

Comments
 (0)