Skip to content

Commit 9923fbc

Browse files
committed
Fix symbols
1 parent af86110 commit 9923fbc

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ object SymDenotations {
498498
/** `fullName` where `.' is the separator character */
499499
def fullName(using Context): Name = fullNameSeparated(QualifiedName)
500500

501-
private var myTargetName: Name = null
501+
private var myTargetName: Name | Null = null
502502

503503
private def computeTargetName(targetNameAnnot: Option[Annotation])(using Context): Name =
504504
targetNameAnnot match
@@ -529,9 +529,9 @@ object SymDenotations {
529529
else carrier.getAnnotation(defn.TargetNameAnnot)
530530
myTargetName = computeTargetName(targetNameAnnot)
531531
if name.is(SuperAccessorName) then
532-
myTargetName = myTargetName.unmangle(List(ExpandedName, SuperAccessorName, ExpandPrefixName))
532+
myTargetName = myTargetName.nn.unmangle(List(ExpandedName, SuperAccessorName, ExpandPrefixName))
533533

534-
myTargetName
534+
myTargetName.nn
535535

536536
// ----- Tests -------------------------------------------------
537537

@@ -834,7 +834,7 @@ object SymDenotations {
834834
* As a side effect, drop Local flags of members that are not accessed via the ThisType
835835
* of their owner.
836836
*/
837-
final def isAccessibleFrom(pre: Type, superAccess: Boolean = false, whyNot: StringBuffer = null)(using Context): Boolean = {
837+
final def isAccessibleFrom(pre: Type, superAccess: Boolean = false, whyNot: StringBuffer | Null = null)(using Context): Boolean = {
838838

839839
/** Are we inside definition of `boundary`?
840840
* If this symbol is Java defined, package structure is interpreted to be flat.
@@ -864,7 +864,7 @@ object SymDenotations {
864864
/** Is protected access to target symbol permitted? */
865865
def isProtectedAccessOK: Boolean =
866866
inline def fail(str: String): false =
867-
if whyNot != null then whyNot.append(str)
867+
if whyNot != null then whyNot.nn.append(str)
868868
false
869869
val cls = owner.enclosingSubClass
870870
if !cls.exists then
@@ -1240,7 +1240,7 @@ object SymDenotations {
12401240
.map(tpd.definedSym)
12411241
.find(_.name == name)
12421242
.getOrElse(NoSymbol)
1243-
else if (ctx.scope == null)
1243+
else if ((ctx.scope: Scope | Null) == null) // TODO
12441244
NoSymbol
12451245
else if (ctx.scope.lookup(this.name) == symbol)
12461246
ctx.scope.lookup(name)
@@ -1534,10 +1534,10 @@ object SymDenotations {
15341534
owner: Symbol = this.owner,
15351535
name: Name = this.name,
15361536
initFlags: FlagSet = UndefinedFlags,
1537-
info: Type = null,
1538-
privateWithin: Symbol = null,
1539-
annotations: List[Annotation] = null,
1540-
rawParamss: List[List[Symbol]] = null)(
1537+
info: Type | Null = null,
1538+
privateWithin: Symbol | Null = null,
1539+
annotations: List[Annotation] | Null = null,
1540+
rawParamss: List[List[Symbol]] | Null = null)(
15411541
using Context): SymDenotation = {
15421542
// simulate default parameters, while also passing implicit context ctx to the default values
15431543
val initFlags1 = (if (initFlags != UndefinedFlags) initFlags else this.flags)
@@ -1562,7 +1562,7 @@ object SymDenotations {
15621562
/** Are `info1` and `info2` ClassInfo types with different parents?
15631563
* @param completersMatter if `true`, consider parents changed if `info1` or `info2 `is a type completer
15641564
*/
1565-
protected def changedClassParents(info1: Type, info2: Type, completersMatter: Boolean): Boolean =
1565+
protected def changedClassParents(info1: Type | Null, info2: Type | Null, completersMatter: Boolean): Boolean =
15661566
info2 match {
15671567
case info2: ClassInfo =>
15681568
info1 match {
@@ -1704,15 +1704,15 @@ object SymDenotations {
17041704

17051705
// ----- caches -------------------------------------------------------
17061706

1707-
private var myTypeParams: List[TypeSymbol] = null
1707+
private var myTypeParams: List[TypeSymbol] | Null = null
17081708
private var fullNameCache: SimpleIdentityMap[QualifiedNameKind, Name] = SimpleIdentityMap.empty
17091709

1710-
private var myMemberCache: EqHashMap[Name, PreDenotation] = null
1710+
private var myMemberCache: EqHashMap[Name, PreDenotation] | Null = null
17111711
private var myMemberCachePeriod: Period = Nowhere
17121712

17131713
/** A cache from types T to baseType(T, C) */
17141714
type BaseTypeMap = EqHashMap[CachedType, Type]
1715-
private var myBaseTypeCache: BaseTypeMap = null
1715+
private var myBaseTypeCache: BaseTypeMap | Null = null
17161716
private var myBaseTypeCachePeriod: Period = Nowhere
17171717

17181718
private var baseDataCache: BaseData = BaseData.None
@@ -1753,7 +1753,7 @@ object SymDenotations {
17531753
invalidateMemberNamesCache()
17541754

17551755
def invalidateMemberCachesFor(sym: Symbol)(using Context): Unit =
1756-
if myMemberCache != null then myMemberCache.remove(sym.name)
1756+
if myMemberCache != null then myMemberCache.uncheckedNN.remove(sym.name)
17571757
if !sym.flagsUNSAFE.is(Private) then
17581758
invalidateMemberNamesCache()
17591759
if sym.isWrappedToplevelDef then

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package core
44

5-
// import scala.language.{unsafeNulls => _}
5+
import scala.language.{unsafeNulls => _}
66

77
import Periods._
88
import Names._
@@ -74,7 +74,7 @@ object Symbols {
7474

7575
/** The tree defining the symbol at pickler time, EmptyTree if none was retained */
7676
def defTree: Tree =
77-
if (myDefTree == null) tpd.EmptyTree else myDefTree
77+
if (myDefTree == null) tpd.EmptyTree else myDefTree.nn
7878

7979
/** Set defining tree if this symbol retains its definition tree */
8080
def defTree_=(tree: Tree)(using Context): Unit =
@@ -91,7 +91,7 @@ object Symbols {
9191
ctx.settings.YcheckInit.value // initialization check
9292

9393
/** The last denotation of this symbol */
94-
private var lastDenot: SymDenotation = _
94+
private var lastDenot: SymDenotation | Null = _
9595
private var checkedPeriod: Period = Nowhere
9696

9797
private[core] def invalidateDenotCache(): Unit = { checkedPeriod = Nowhere }
@@ -106,7 +106,7 @@ object Symbols {
106106
/** The current denotation of this symbol */
107107
final def denot(using Context): SymDenotation = {
108108
util.Stats.record("Symbol.denot")
109-
val lastd = lastDenot
109+
val lastd = lastDenot.nn
110110
if (checkedPeriod == ctx.period) lastd
111111
else computeDenot(lastd)
112112
}
@@ -128,14 +128,14 @@ object Symbols {
128128

129129
/** The original denotation of this symbol, without forcing anything */
130130
final def originDenotation: SymDenotation =
131-
lastDenot.initial
131+
lastDenot.nn.initial
132132

133133
/** The last known denotation of this symbol, without going through `current` */
134134
final def lastKnownDenotation: SymDenotation =
135-
lastDenot
135+
lastDenot.nn
136136

137137
private[core] def defRunId: RunId =
138-
if (lastDenot == null) NoRunId else lastDenot.validFor.runId
138+
if (lastDenot == null) NoRunId else lastDenot.nn.validFor.runId
139139

140140
/** Does this symbol come from a currently compiled source file? */
141141
final def isDefinedInCurrentRun(using Context): Boolean =
@@ -150,17 +150,18 @@ object Symbols {
150150

151151
/** Is symbol valid in current run? */
152152
final def isValidInCurrentRun(using Context): Boolean =
153-
(lastDenot.validFor.runId == ctx.runId || stillValid(lastDenot)) &&
154-
(lastDenot.symbol eq this)
153+
val d = lastDenot.nn
154+
(d.validFor.runId == ctx.runId || stillValid(d)) &&
155+
(d.symbol eq this)
155156
// the last condition is needed because under ctx.staleOK overwritten
156157
// members keep denotations pointing to the new symbol, so the validity
157158
// periods check out OK. But once a package member is overridden it is not longer
158159
// valid. If the option would be removed, the check would be no longer needed.
159160

160161
final def isTerm(using Context): Boolean =
161-
(if (defRunId == ctx.runId) lastDenot else denot).isTerm
162+
(if (defRunId == ctx.runId) lastDenot.nn else denot).isTerm
162163
final def isType(using Context): Boolean =
163-
(if (defRunId == ctx.runId) lastDenot else denot).isType
164+
(if (defRunId == ctx.runId) lastDenot.nn else denot).isType
164165
final def asTerm(using Context): TermSymbol = {
165166
assert(isTerm, s"asTerm called on not-a-Term $this" );
166167
asInstanceOf[TermSymbol]
@@ -189,14 +190,14 @@ object Symbols {
189190

190191
/** The symbol's signature if it is completed or a method, NotAMethod otherwise. */
191192
final def signature(using Context): Signature =
192-
if (lastDenot != null && (lastDenot.isCompleted || lastDenot.is(Method)))
193+
if (lastDenot != null && (lastDenot.uncheckedNN.isCompleted || lastDenot.uncheckedNN.is(Method)))
193194
denot.signature
194195
else
195196
Signature.NotAMethod
196197

197198
/** Special cased here, because it may be used on naked symbols in substituters */
198199
final def isStatic(using Context): Boolean =
199-
lastDenot != null && lastDenot.initial.isStatic
200+
lastDenot != null && lastDenot.uncheckedNN.initial.isStatic
200201

201202
/** This symbol entered into owner's scope (owner must be a class). */
202203
final def entered(using Context): this.type = {
@@ -264,7 +265,7 @@ object Symbols {
264265
* Overridden in ClassSymbol
265266
*/
266267
def associatedFile(using Context): AbstractFile | Null =
267-
if (lastDenot == null) null else lastDenot.topLevelClass.associatedFile
268+
if (lastDenot == null) null else lastDenot.uncheckedNN.topLevelClass.associatedFile
268269

269270
/** The class file from which this class was generated, null if not applicable. */
270271
final def binaryFile(using Context): AbstractFile | Null = {

0 commit comments

Comments
 (0)