File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
compiler/src/dotty/tools/dotc/sbt Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,13 @@ private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.
232
232
throw ex
233
233
}
234
234
235
+ /** Reused EqHashSet, safe to use as each TypeDependencyTraverser is used atomically
236
+ * Avoid cycles by remembering both the types (testcase:
237
+ * tests/run/enum-values.scala) and the symbols of named types (testcase:
238
+ * tests/pos-java-interop/i13575) we've seen before.
239
+ */
240
+ private val scratchSeen = new util.EqHashSet [Symbol | Type ](128 )
241
+
235
242
/** Traverse a used type and record all the dependencies we need to keep track
236
243
* of for incremental recompilation.
237
244
*
@@ -268,15 +275,13 @@ private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.
268
275
private abstract class TypeDependencyTraverser (using Context ) extends TypeTraverser () {
269
276
protected def addDependency (symbol : Symbol ): Unit
270
277
271
- // Avoid cycles by remembering both the types (testcase:
272
- // tests/run/enum-values.scala) and the symbols of named types (testcase:
273
- // tests/pos-java-interop/i13575) we've seen before.
274
- val seen = new util.EqHashSet [Symbol | Type ](128 ) // 64 still needs to grow often for scala3-compiler
275
- def traverse (tp : Type ): Unit = if seen.add(tp) then {
278
+ scratchSeen.clear(resetToInitial = false )
279
+
280
+ def traverse (tp : Type ): Unit = if scratchSeen.add(tp) then {
276
281
tp match {
277
282
case tp : NamedType =>
278
283
val sym = tp.symbol
279
- if ! sym.is(Package ) && seen .add(sym) then
284
+ if ! sym.is(Package ) && scratchSeen .add(sym) then
280
285
addDependency(sym)
281
286
if ! sym.isClass then traverse(tp.info)
282
287
traverse(tp.prefix)
You can’t perform that action at this time.
0 commit comments