@@ -100,7 +100,7 @@ class TyperState(previous: TyperState /* | Null */) {
100
100
def uncommittedAncestor : TyperState =
101
101
if (isCommitted) previous.uncommittedAncestor else this
102
102
103
- private [this ] var testReporter : StoreReporter = null
103
+ private [this ] var testReporter : TestReporter = null
104
104
105
105
/** Test using `op`. If current typerstate is shared, run `op` in a fresh exploration
106
106
* typerstate. If it is unshared, run `op` in current typerState, restoring typerState
@@ -116,15 +116,17 @@ class TyperState(previous: TyperState /* | Null */) {
116
116
val savedCommitted = isCommitted
117
117
myIsCommittable = false
118
118
myReporter = {
119
- if (testReporter == null ) {
120
- testReporter = new StoreReporter (reporter)
119
+ if (testReporter == null || testReporter.inUse ) {
120
+ testReporter = new TestReporter (reporter)
121
121
} else {
122
122
testReporter.reset()
123
123
}
124
+ testReporter.inUse = true
124
125
testReporter
125
126
}
126
127
try op(ctx)
127
128
finally {
129
+ testReporter.inUse = false
128
130
resetConstraintTo(savedConstraint)
129
131
myReporter = savedReporter
130
132
myIsCommittable = savedCommittable
@@ -189,3 +191,14 @@ class TyperState(previous: TyperState /* | Null */) {
189
191
190
192
def stateChainStr : String = s " $this${if (previous == null ) " " else previous.stateChainStr}"
191
193
}
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