File tree 2 files changed +25
-3
lines changed
compiler/src/dotty/tools/dotc/core 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,10 @@ object SymDenotations {
164
164
private def adaptFlags (flags : FlagSet ) = if (isType) flags.toTypeFlags else flags.toTermFlags
165
165
166
166
/** Update the flag set */
167
- final def flags_= (flags : FlagSet ): Unit =
167
+ final def flags_= (flags : FlagSet ): Unit = {
168
168
myFlags = adaptFlags(flags)
169
+ symbol.updateFlagsCache(this , myFlags)
170
+ }
169
171
170
172
/** Set given flags(s) of this denotation */
171
173
final def setFlag (flags : FlagSet ): Unit = { myFlags |= flags }
@@ -263,6 +265,7 @@ object SymDenotations {
263
265
*/
264
266
if (Config .checkNoSkolemsInInfo) assertNoSkolems(tp)
265
267
myInfo = tp
268
+ symbol.updateInfoCache(this , tp)
266
269
}
267
270
268
271
/** The name, except
Original file line number Diff line number Diff line change @@ -434,11 +434,30 @@ object Symbols {
434
434
private [this ] var lastDenot : SymDenotation = _
435
435
private [this ] var checkedPeriod : Period = Nowhere
436
436
437
+ private [this ] var cachedName : Name = _
438
+ private [this ] var cachedOwner : Symbol = _
439
+ private [this ] var cachedInfo : Type = _
440
+ private [this ] var cachedFlags : FlagSet = _
441
+
437
442
private [core] def invalidateDenotCache () = { checkedPeriod = Nowhere }
438
443
444
+ private [core] def updateInfoCache (d : SymDenotation , info : Type ) =
445
+ if (lastDenot `eq` d) cachedInfo = info
446
+
447
+ private [core] def updateFlagsCache (d : SymDenotation , flags : FlagSet ) =
448
+ if (lastDenot `eq` d) cachedFlags = flags
449
+
450
+ private [this ] def setLastDenot (d : SymDenotation ) = {
451
+ lastDenot = d
452
+ cachedName = d.name
453
+ cachedOwner = d.owner
454
+ cachedInfo = d.infoOrCompleter
455
+ cachedFlags = d.flagsUNSAFE
456
+ }
457
+
439
458
/** Set the denotation of this symbol */
440
459
private [core] def denot_= (d : SymDenotation ) = {
441
- lastDenot = d
460
+ setLastDenot(d)
442
461
checkedPeriod = Nowhere
443
462
}
444
463
@@ -461,7 +480,7 @@ object Symbols {
461
480
protected def recomputeDenot (lastd : SymDenotation )(implicit ctx : Context ) = {
462
481
Stats .record(" Symbol.recomputeDenot" )
463
482
val newd = lastd.current.asInstanceOf [SymDenotation ]
464
- lastDenot = newd
483
+ setLastDenot( newd)
465
484
newd
466
485
}
467
486
You can’t perform that action at this time.
0 commit comments