Skip to content

Commit 5bf7eea

Browse files
committed
remove uncheckedNN and toOption
1 parent 4bbfe06 commit 5bf7eea

34 files changed

+107
-130
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
213213
val acquiredStack = if needStackStash then stack.acquireFullStack() else null
214214
val stashLocals =
215215
if acquiredStack == null then null
216-
else acquiredStack.uncheckedNN.filter(_ != UNIT).map(btpe => locals.makeTempLocal(btpe))
216+
else acquiredStack.nn.filter(_ != UNIT).map(btpe => locals.makeTempLocal(btpe))
217217

218218
val hasFinally = (finalizer != tpd.EmptyTree)
219219

@@ -240,7 +240,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
240240
*/
241241

242242
if stashLocals != null then
243-
val stashLocalsNN = stashLocals.uncheckedNN // why is this necessary?
243+
val stashLocalsNN = stashLocals.nn // why is this necessary?
244244
for i <- (stashLocalsNN.length - 1) to 0 by -1 do
245245
val local = stashLocalsNN(i)
246246
bc.store(local.idx, local.tk)
@@ -398,7 +398,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
398398
*/
399399

400400
if stashLocals != null then
401-
val stashLocalsNN = stashLocals.uncheckedNN // why is this necessary?
401+
val stashLocalsNN = stashLocals.nn // why is this necessary?
402402

403403
val resultLoc =
404404
if kind == UNIT then null

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object Trees {
7575
*/
7676
final def tpe: T =
7777
if myTpe == null then throw UnAssignedTypeException(this)
78-
myTpe.uncheckedNN
78+
myTpe.nn
7979

8080
/** Copy `tpe` attribute from tree `from` into this tree, independently
8181
* whether it is null or not.
@@ -295,7 +295,7 @@ object Trees {
295295
private var myMods: untpd.Modifiers | Null = uninitialized
296296

297297
private[dotc] def rawMods: untpd.Modifiers =
298-
if (myMods == null) untpd.EmptyModifiers else myMods.uncheckedNN
298+
if (myMods == null) untpd.EmptyModifiers else myMods.nn
299299

300300
def withAnnotations(annots: List[untpd.Tree]): ThisTree[Untyped] = withMods(rawMods.withAnnotations(annots))
301301

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
279279
val previousParamRefs: ListBuffer[TermRef] =
280280
// It is ok to assign `null` here.
281281
// If `isParamDependent == false`, the value of `previousParamRefs` is not used.
282-
if isParamDependent then mutable.ListBuffer[TermRef]() else (null: ListBuffer[TermRef] | Null).uncheckedNN
282+
if isParamDependent then mutable.ListBuffer[TermRef]() else (null: ListBuffer[TermRef] | Null).nn
283283

284284
def valueParam(name: TermName, origInfo: Type, isErased: Boolean): TermSymbol =
285285
val maybeImplicit =
@@ -1378,7 +1378,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13781378
def rootTrees(using Context): List[Tree] =
13791379
if (ctx.settings.YretainTrees.value) {
13801380
if (myTrees == null) myTrees = computeRootTrees
1381-
myTrees.uncheckedNN
1381+
myTrees.nn
13821382
}
13831383
else computeRootTrees
13841384

compiler/src/dotty/tools/dotc/cc/Capability.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ object Capabilities:
571571
def singletonCaptureSet(using Context): CaptureSet.Const =
572572
if mySingletonCaptureSet == null then
573573
mySingletonCaptureSet = CaptureSet(this)
574-
mySingletonCaptureSet.uncheckedNN
574+
mySingletonCaptureSet.nn
575575

576576
/** The capture set of the type underlying this reference */
577577
def captureSetOfInfo(using Context): CaptureSet =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ object Contexts {
887887
finally ctx.base.comparersInUse = saved
888888
end comparing
889889

890-
@sharable val NoContext: Context = new FreshContext((null: ContextBase | Null).uncheckedNN) {
890+
@sharable val NoContext: Context = new FreshContext((null: ContextBase | Null).nn) {
891891
override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null, false)(this: @unchecked)
892892
setSource(NoSource)
893893
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class GadtConstraint private (
123123
def apply(tp: Type): Type = externalize(tp, this)(using mapCtx)
124124

125125
def tvarOrError(sym: Symbol)(using Context): TypeVar =
126-
mapping(sym).ensuring(_ != null, i"not a constrainable symbol: $sym").uncheckedNN
126+
mapping(sym).ensuring(_ != null, i"not a constrainable symbol: $sym").nn
127127

128128
@tailrec final def stripInternalTypeVar(tp: Type): Type = tp match
129129
case tv: TypeVar =>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,17 +896,17 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
896896

897897
/** The uninstantiated typevars of this constraint */
898898
def uninstVars: collection.Seq[TypeVar] = {
899-
if (myUninstVars == null || myUninstVars.uncheckedNN.exists(_.isPermanentlyInstantiated)) {
899+
if (myUninstVars == null || myUninstVars.nn.exists(_.isPermanentlyInstantiated)) {
900900
myUninstVars = new mutable.ArrayBuffer[TypeVar]
901901
boundsMap.foreachBinding { (poly, entries) =>
902902
for (i <- 0 until paramCount(entries))
903903
typeVar(entries, i) match {
904-
case tv: TypeVar if !tv.isPermanentlyInstantiated && isBounds(entries(i)) => myUninstVars.uncheckedNN += tv
904+
case tv: TypeVar if !tv.isPermanentlyInstantiated && isBounds(entries(i)) => myUninstVars.nn += tv
905905
case _ =>
906906
}
907907
}
908908
}
909-
myUninstVars.uncheckedNN
909+
myUninstVars.nn
910910
}
911911

912912
// ---------- Checking -----------------------------------------------

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ object Scopes {
135135
final def lookupAll(name: Name)(using Context): Iterator[Symbol] = new Iterator[Symbol] {
136136
var e = lookupEntry(name)
137137
def hasNext: Boolean = e != null
138-
def next(): Symbol = { val r = e.nn.sym; e = lookupNextEntry(e.uncheckedNN); r }
138+
def next(): Symbol = { val r = e.nn.sym; e = lookupNextEntry(e.nn); r }
139139
}
140140

141141
/** Does this scope contain a reference to `sym` when looking up `name`? */
@@ -180,7 +180,7 @@ object Scopes {
180180
else
181181
drop()
182182
// TODO: improve flow typing to handle this case
183-
if result == null then this else result.uncheckedNN
183+
if result == null then this else result.nn
184184

185185
def implicitDecls(using Context): List[TermRef] = Nil
186186

@@ -257,7 +257,7 @@ object Scopes {
257257

258258
/** create and enter a scope entry with given name and symbol */
259259
protected def newScopeEntry(name: Name, sym: Symbol)(using Context): ScopeEntry = {
260-
ensureCapacity(if (hashTable != null) hashTable.uncheckedNN.length else MinHashedScopeSize)
260+
ensureCapacity(if (hashTable != null) hashTable.nn.length else MinHashedScopeSize)
261261
val e = new ScopeEntry(name, sym, this)
262262
e.prev = lastEntry
263263
lastEntry = e
@@ -384,7 +384,7 @@ object Scopes {
384384
e = e.prev
385385
}
386386
if ((e == null) && (synthesize != null)) {
387-
val sym = synthesize.uncheckedNN(name)
387+
val sym = synthesize.nn(name)
388388
if (sym.exists) newScopeEntry(sym.name, sym) else e
389389
}
390390
else e
@@ -394,9 +394,9 @@ object Scopes {
394394
override final def lookupNextEntry(entry: ScopeEntry)(using Context): ScopeEntry | Null = {
395395
var e: ScopeEntry | Null = entry
396396
if (hashTable != null)
397-
while ({ e = e.nn.tail ; (e != null) && e.uncheckedNN.name != entry.name }) ()
397+
while ({ e = e.nn.tail ; (e != null) && e.nn.name != entry.name }) ()
398398
else
399-
while ({ e = e.nn.prev ; (e != null) && e.uncheckedNN.name != entry.name }) ()
399+
while ({ e = e.nn.prev ; (e != null) && e.nn.name != entry.name }) ()
400400
e
401401
}
402402

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ object SymDenotations {
19061906
invalidateMemberNamesCache()
19071907

19081908
def invalidateMemberCachesFor(sym: Symbol)(using Context): Unit =
1909-
if myMemberCache != null then myMemberCache.uncheckedNN.remove(sym.name)
1909+
if myMemberCache != null then myMemberCache.nn.remove(sym.name)
19101910
if !sym.flagsUNSAFE.is(Private) then
19111911
invalidateMemberNamesCache()
19121912
if sym.isWrappedToplevelDef then
@@ -2136,7 +2136,7 @@ object SymDenotations {
21362136
*/
21372137
def replace(prev: Symbol, replacement: Symbol)(using Context): Unit = {
21382138
unforcedDecls.openForMutations.replace(prev, replacement)
2139-
if (myMemberCache != null) myMemberCache.uncheckedNN.remove(replacement.name)
2139+
if (myMemberCache != null) myMemberCache.nn.remove(replacement.name)
21402140
}
21412141

21422142
/** Delete symbol from current scope.
@@ -2147,7 +2147,7 @@ object SymDenotations {
21472147
val scope = info.decls.openForMutations
21482148
scope.unlink(sym, sym.name)
21492149
if sym.name != sym.originalName then scope.unlink(sym, sym.originalName)
2150-
if (myMemberCache != null) myMemberCache.uncheckedNN.remove(sym.name)
2150+
if (myMemberCache != null) myMemberCache.nn.remove(sym.name)
21512151
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
21522152
}
21532153

@@ -3040,7 +3040,7 @@ object SymDenotations {
30403040
: (List[ClassSymbol], BaseClassSet) = {
30413041
assert(isValid)
30423042
CyclicReference.trace("compute the base classes of ", clsd.symbol):
3043-
if cache != null then cache.uncheckedNN
3043+
if cache != null then cache.nn
30443044
else
30453045
if (locked) throw CyclicReference(clsd)
30463046
locked = true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ object Symbols extends SymUtils {
208208

209209
/** The symbol's signature if it is completed or a method, NotAMethod otherwise. */
210210
final def signature(using Context): Signature =
211-
if lastDenot.uncheckedNN.isCompleted || lastDenot.uncheckedNN.is(Method) then
211+
if lastDenot.nn.isCompleted || lastDenot.nn.is(Method) then
212212
denot.signature
213213
else
214214
Signature.NotAMethod

0 commit comments

Comments
 (0)