@@ -18,12 +18,12 @@ package scala
18
18
package reflect
19
19
package internal
20
20
21
- import scala .collection .immutable
22
- import scala .collection .mutable .{ListBuffer , Stack }
23
- import util .{ ReusableInstance , Statistics , shortClassOfInstance }
24
- import Flags ._
25
21
import scala .annotation .tailrec
22
+ import scala .collection .mutable .{ArrayBuffer , ListBuffer }
26
23
import scala .reflect .io .{AbstractFile , NoAbstractFile }
24
+
25
+ import util .{ReusableInstance , Statistics , shortClassOfInstance }
26
+ import Flags ._
27
27
import Variance ._
28
28
29
29
trait Symbols extends api.Symbols { self : SymbolTable =>
@@ -36,15 +36,15 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
36
36
protected def nextId () = { ids += 1 ; ids }
37
37
38
38
/** 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 ]
40
40
def recursionTable = _recursionTable
41
- def recursionTable_= (value : immutable. Map [Symbol , Int ]) = _recursionTable = value
41
+ def recursionTable_= (value : Map [Symbol , Int ]) = _recursionTable = value
42
42
43
43
private [this ] var _lockedCount = 0
44
44
def lockedCount = this ._lockedCount
45
45
def lockedCount_= (i : Int ) = _lockedCount = i
46
46
47
- private [this ] val _lockingTrace = Stack .empty[Symbol ]
47
+ private [this ] val _lockingTrace = ArrayBuffer .empty[Symbol ]
48
48
private [this ] val lockTracing : Boolean = self.isSymbolLockTracingEnabled
49
49
50
50
@ deprecated(" Global existential IDs no longer used" , " 2.12.1" )
@@ -568,7 +568,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
568
568
569
569
// Lock a symbol, using the handler if the recursion depth becomes too great.
570
570
private [scala] def lock (handler : => Unit ): Boolean = {
571
- if (lockTracing) _lockingTrace.push (this )
571
+ if (lockTracing) _lockingTrace.addOne (this )
572
572
if ((_rawflags & LOCKED ) != 0L ) {
573
573
if (settings.Yrecursion .value != 0 ) {
574
574
recursionTable.get(this ) match {
@@ -599,7 +599,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
599
599
if ((_rawflags & LOCKED ) != 0L ) {
600
600
_rawflags &= ~ LOCKED
601
601
if (lockTracing && ! _lockingTrace.isEmpty)
602
- _lockingTrace.remove(idx = 0 , count = 1 )
602
+ _lockingTrace.remove(index = _lockingTrace.size - 1 , count = 1 ) // dropRightInPlace( 1)
603
603
if (settings.Yrecursion .value != 0 )
604
604
recursionTable -= this
605
605
}
@@ -1565,14 +1565,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
1565
1565
setInfo(ErrorType )
1566
1566
val trace =
1567
1567
if (lockTracing) {
1568
- val t = _lockingTrace.toList
1568
+ val t = _lockingTrace.toArray
1569
1569
_lockingTrace.clear()
1570
1570
t
1571
- } else Nil
1571
+ } else CyclicReference .emptyTrace
1572
1572
throw CyclicReference (this , tp, trace)
1573
1573
}
1574
1574
} else {
1575
- if (lockTracing) _lockingTrace.push (this )
1575
+ if (lockTracing) _lockingTrace.addOne (this )
1576
1576
_rawflags |= LOCKED
1577
1577
}
1578
1578
val current = phase
@@ -3849,10 +3849,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
3849
3849
else closestEnclMethod(from.owner)
3850
3850
3851
3851
/** 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 )
3853
3853
extends TypeError (s " illegal cyclic reference involving $sym" ) {
3854
3854
if (settings.isDebug) printStackTrace()
3855
3855
}
3856
+ object CyclicReference {
3857
+ val emptyTrace : Array [Symbol ] = Array .empty[Symbol ]
3858
+ }
3856
3859
3857
3860
/** A class for type histories */
3858
3861
private final case class TypeHistory protected (private var _validFrom : Period , private var _info : Type , private var _prev : TypeHistory ) {
0 commit comments