@@ -18,12 +18,12 @@ package scala
1818package reflect
1919package internal
2020
21- import scala .collection .immutable
22- import scala .collection .mutable .{ListBuffer , Stack }
23- import util .{ ReusableInstance , Statistics , shortClassOfInstance }
24- import Flags ._
2521import scala .annotation .tailrec
22+ import scala .collection .mutable .{ArrayBuffer , ListBuffer }
2623import scala .reflect .io .{AbstractFile , NoAbstractFile }
24+
25+ import util .{ReusableInstance , Statistics , shortClassOfInstance }
26+ import Flags ._
2727import Variance ._
2828
2929trait Symbols extends api.Symbols { self : SymbolTable =>
@@ -36,15 +36,15 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
3636 protected def nextId () = { ids += 1 ; ids }
3737
3838 /** Used to keep track of the recursion depth on locked symbols */
39- private [this ] var _recursionTable = immutable. Map .empty[Symbol , Int ]
39+ private [this ] var _recursionTable = Map .empty[Symbol , Int ]
4040 def recursionTable = _recursionTable
41- def recursionTable_= (value : immutable. Map [Symbol , Int ]) = _recursionTable = value
41+ def recursionTable_= (value : Map [Symbol , Int ]) = _recursionTable = value
4242
4343 private [this ] var _lockedCount = 0
4444 def lockedCount = this ._lockedCount
4545 def lockedCount_= (i : Int ) = _lockedCount = i
4646
47- private [this ] val _lockingTrace = Stack .empty[Symbol ]
47+ private [this ] val _lockingTrace = ArrayBuffer .empty[Symbol ]
4848 private [this ] val lockTracing : Boolean = self.isSymbolLockTracingEnabled
4949
5050 @ deprecated(" Global existential IDs no longer used" , " 2.12.1" )
@@ -568,7 +568,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
568568
569569 // Lock a symbol, using the handler if the recursion depth becomes too great.
570570 private [scala] def lock (handler : => Unit ): Boolean = {
571- if (lockTracing) _lockingTrace.push (this )
571+ if (lockTracing) _lockingTrace.addOne (this )
572572 if ((_rawflags & LOCKED ) != 0L ) {
573573 if (settings.Yrecursion .value != 0 ) {
574574 recursionTable.get(this ) match {
@@ -599,7 +599,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
599599 if ((_rawflags & LOCKED ) != 0L ) {
600600 _rawflags &= ~ LOCKED
601601 if (lockTracing && ! _lockingTrace.isEmpty)
602- _lockingTrace.remove(idx = 0 , count = 1 )
602+ _lockingTrace.remove(index = _lockingTrace.size - 1 , count = 1 ) // dropRightInPlace( 1)
603603 if (settings.Yrecursion .value != 0 )
604604 recursionTable -= this
605605 }
@@ -1565,14 +1565,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
15651565 setInfo(ErrorType )
15661566 val trace =
15671567 if (lockTracing) {
1568- val t = _lockingTrace.toList
1568+ val t = _lockingTrace.toArray
15691569 _lockingTrace.clear()
15701570 t
1571- } else Nil
1571+ } else CyclicReference .emptyTrace
15721572 throw CyclicReference (this , tp, trace)
15731573 }
15741574 } else {
1575- if (lockTracing) _lockingTrace.push (this )
1575+ if (lockTracing) _lockingTrace.addOne (this )
15761576 _rawflags |= LOCKED
15771577 }
15781578 val current = phase
@@ -3849,10 +3849,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
38493849 else closestEnclMethod(from.owner)
38503850
38513851 /** An exception for cyclic references of symbol definitions */
3852- case class CyclicReference (sym : Symbol , info : Type , trace : List [Symbol ] = Nil )
3852+ case class CyclicReference (sym : Symbol , info : Type , trace : Array [Symbol ] = CyclicReference .emptyTrace )
38533853 extends TypeError (s " illegal cyclic reference involving $sym" ) {
38543854 if (settings.isDebug) printStackTrace()
38553855 }
3856+ object CyclicReference {
3857+ val emptyTrace : Array [Symbol ] = Array .empty[Symbol ]
3858+ }
38563859
38573860 /** A class for type histories */
38583861 private final case class TypeHistory protected (private var _validFrom : Period , private var _info : Type , private var _prev : TypeHistory ) {
0 commit comments