@@ -20,6 +20,7 @@ import StdNames._
20
20
import NameOps ._
21
21
import transform .SymUtils ._
22
22
import NameKinds .LazyImplicitName
23
+ import Annotations .Annotation
23
24
import ast .tpd
24
25
import tpd .{Tree , TreeProvider , TreeOps , EmptyTree , NameTree }
25
26
import ast .TreeTypeMap
@@ -180,6 +181,9 @@ object Symbols {
180
181
/** The last known denotation of this symbol, without going through `current` */
181
182
def lastKnownDenotation : SymDenotation = lastDenot
182
183
184
+ def classDenot (using Context ): ClassDenotation =
185
+ _self.denot.asInstanceOf [ClassDenotation ]
186
+
183
187
private [core] def defRunId : RunId =
184
188
lastDenot.validFor.runId
185
189
@@ -270,18 +274,18 @@ object Symbols {
270
274
case owner : ClassSymbol =>
271
275
if owner.is(Package ) then
272
276
d.validFor |= InitialPeriod
273
- if d.is(Module ) then d.moduleClass.validFor |= InitialPeriod
277
+ if d.is(Module ) then d.moduleClass.denot. validFor |= InitialPeriod
274
278
else
275
- owner.ensureFreshScopeAfter(phase)
279
+ owner.classDenot. ensureFreshScopeAfter(phase)
276
280
assert(isPrivate || phase.changesMembers, i " $_self entered in $owner at undeclared phase $phase" )
277
281
_self.entered
278
282
case _ => _self
279
283
280
284
/** Remove symbol from scope of owning class */
281
285
final def drop ()(using Context ): Unit =
282
286
val d = denot
283
- d.owner.asClass .delete(_self)
284
- if d.is(Module ) then d.owner.asClass .delete(d.moduleClass)
287
+ d.owner.classDenot .delete(_self)
288
+ if d.is(Module ) then d.owner.classDenot .delete(d.moduleClass)
285
289
286
290
/** Remove symbol from scope of owning class after given `phase`. Create a fresh
287
291
* denotation for its owner class if the class does not already have one that starts being valid after `phase`.
@@ -293,7 +297,7 @@ object Symbols {
293
297
else
294
298
val d = denot
295
299
assert(! d.owner.is(Package ))
296
- d.owner.asClass .ensureFreshScopeAfter(phase)
300
+ d.owner.classDenot .ensureFreshScopeAfter(phase)
297
301
assert(isPrivate || phase.changesMembers, i " $_self deleted in ${d.owner} at undeclared phase $phase" )
298
302
drop()
299
303
@@ -365,6 +369,39 @@ object Symbols {
365
369
else
366
370
_self
367
371
372
+ def exists (using Context ): Boolean = _self.denot.exists
373
+ def owner (using Context ): Symbol = _self.denot.owner
374
+ def typeParams (using Context ): List [TypeSymbol ] = _self.denot.typeParams
375
+ def thisType (using Context ): Type = _self.denot.thisType
376
+ def typeRef (using Context ): TypeRef = _self.denot.typeRef
377
+ def termRef (using Context ): TermRef = _self.denot.termRef
378
+ def isCompleted (using Context ): Boolean = _self.denot.isCompleted
379
+ def isCompleting (using Context ): Boolean = _self.denot.isCompleting
380
+ def ensureCompleted ()(using Context ): Unit = _self.denot.ensureCompleted()
381
+ def unforcedDecls (using Context ): Scope = _self.denot.unforcedDecls
382
+ def appliedRef (using Context ): Type = _self.denot.appliedRef
383
+ def namedType (using Context ): NamedType = _self.denot.namedType
384
+ def unforcedAnnotation (cls : Symbol )(using Context ): Option [Annotation ] = _self.denot.unforcedAnnotation(cls)
385
+ def children (using Context ): List [Symbol ] = _self.denot.children
386
+ def topLevelClass (using Context ): Symbol = _self.denot.topLevelClass
387
+ def moduleClass (using Context ): Symbol = _self.denot.moduleClass
388
+ def sourceModule (using Context ): Symbol = _self.denot.sourceModule
389
+ def underlyingSymbol (using Context ): Symbol = _self.denot.underlyingSymbol
390
+ def ownersIterator (using Context ): Iterator [Symbol ] = _self.denot.ownersIterator
391
+ def enclosingClass (using Context ): Symbol = _self.denot.enclosingClass
392
+ def enclosingMethod (using Context ): Symbol = _self.denot.enclosingMethod
393
+ def typeParamCreationFlags (using Context ): FlagSet = _self.denot.typeParamCreationFlags
394
+ // def is(flag: Flag)(using Context): Boolean = _self.denot.is(flag)
395
+ // def is(flag: Flag, butNot: FlagSet)(using Context): Boolean = _self.denot.is(flag, butNot)
396
+ // def isOneOf(fs: FlagSet)(using Context): Boolean = _self.denot.isOneOf(fs)
397
+ // def isOneOf(fs: FlagSet, butNot: FlagSet)(using Context): Boolean = _self.denot.isOneOf(fs, butNot)
398
+ // def isAllOf(fs: FlagSet)(using Context): Boolean = _self.denot.isAllOf(fs)
399
+ // def isAllOf(fs: FlagSet, butNot: FlagSet)(using Context): Boolean = _self.denot.isAllOf(fs, butNot)
400
+ // !!! Dotty problem: overloaded extension methods here lead to failures like
401
+ // Assertion failed: data race? overwriting method isAllOf with method isAllOf in type TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class dotc)),object core),object Symbols),isAllOf),
402
+ // |last sym id = 10301, new sym id = 10299,
403
+ // |last owner = module class Symbols$, new owner = module class Symbols$,
404
+
368
405
// SrcPos types and methods // !!! make them use lastDenot?
369
406
def span : Span = self.span
370
407
def sourcePos (using Context ): SourcePosition = self.sourcePos
@@ -411,6 +448,8 @@ object Symbols {
411
448
def showName (using Context ): String = ctx.printer.nameString(_self)
412
449
def showFullName (using Context ): String = ctx.printer.fullNameString(_self)
413
450
451
+ def debugString : String = self.debugString
452
+
414
453
end extension
415
454
416
455
type TreeOrProvider = TreeProvider | Tree
@@ -474,7 +513,7 @@ object Symbols {
474
513
475
514
def sourceOfClass (using Context ): SourceFile =
476
515
val common = _self.lastKnownDenotation.common.asClass
477
- if ! common.source.exists && ! _self.denot. is(Package ) then
516
+ if ! common.source.exists && ! _self.is(Package ) then
478
517
// this allows sources to be added in annotations after `sourceOfClass` is first called
479
518
val file = _self.associatedFile
480
519
if file != null && file.extension != " class" then
@@ -491,8 +530,10 @@ object Symbols {
491
530
}
492
531
common.source
493
532
494
- def classDenot (using Context ): ClassDenotation =
495
- _self.denot.asInstanceOf [ClassDenotation ]
533
+ private def enter (sym : Symbol , scope : Scope = EmptyScope )(using Context ): Unit =
534
+ _self.classDenot.enter(sym, scope)
535
+
536
+ def classInfo (using Context ): ClassInfo = _self.classDenot.classInfo
496
537
497
538
end extension
498
539
0 commit comments