@@ -100,7 +100,7 @@ class TyperState(previous: TyperState /* | Null */) {
100100 def uncommittedAncestor : TyperState =
101101 if (isCommitted) previous.uncommittedAncestor else this
102102
103- private [this ] var testReporter : StoreReporter = null
103+ private [this ] var testReporter : TestReporter = null
104104
105105 /** Test using `op`. If current typerstate is shared, run `op` in a fresh exploration
106106 * typerstate. If it is unshared, run `op` in current typerState, restoring typerState
@@ -116,15 +116,17 @@ class TyperState(previous: TyperState /* | Null */) {
116116 val savedCommitted = isCommitted
117117 myIsCommittable = false
118118 myReporter = {
119- if (testReporter == null ) {
120- testReporter = new StoreReporter (reporter)
119+ if (testReporter == null || testReporter.inUse ) {
120+ testReporter = new TestReporter (reporter)
121121 } else {
122122 testReporter.reset()
123123 }
124+ testReporter.inUse = true
124125 testReporter
125126 }
126127 try op(ctx)
127128 finally {
129+ testReporter.inUse = false
128130 resetConstraintTo(savedConstraint)
129131 myReporter = savedReporter
130132 myIsCommittable = savedCommittable
@@ -189,3 +191,14 @@ class TyperState(previous: TyperState /* | Null */) {
189191
190192 def stateChainStr : String = s " $this${if (previous == null ) " " else previous.stateChainStr}"
191193}
194+
195+ /** Temporary, reusable reporter used in TyperState#test */
196+ private class TestReporter (outer : Reporter ) extends StoreReporter (outer) {
197+ /** Is this reporter currently used in a test? */
198+ var inUse = false
199+
200+ def reset () = {
201+ assert(! inUse, s " Cannot reset reporter currently in use: $this" )
202+ infos = null
203+ }
204+ }
0 commit comments