Skip to content

Commit 70a7252

Browse files
committed
Update scope
1 parent 479b22f commit 70a7252

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,7 @@ object Contexts {
274274
def effectiveScope(using Context): Scope =
275275
val co: Symbol | Null = owner
276276
if co != null && co.isClass then co.asClass.unforcedDecls
277-
else
278-
val s: Scope | Null = scope
279-
if s == null then EmptyScope else s
277+
else scope
280278

281279
def nestingLevel: Int = effectiveScope.nestingLevel
282280

@@ -828,6 +826,7 @@ object Contexts {
828826
owner = NoSymbol
829827
tree = untpd.EmptyTree
830828
moreProperties = Map(MessageLimiter -> DefaultMessageLimiter())
829+
scope = EmptyScope
831830
source = NoSource
832831
store = initialStore
833832
.updated(settingsStateLoc, settingsGroup.defaultState)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ object SymDenotations {
12371237
.map(tpd.definedSym)
12381238
.find(_.name == name)
12391239
.getOrElse(NoSymbol)
1240-
else if ((ctx.scope: Scope | Null) == null) // TODO
1240+
else if (ctx.scope eq EmptyScope)
12411241
NoSymbol
12421242
else if (ctx.scope.lookup(this.name) == symbol)
12431243
ctx.scope.lookup(name)

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import dotty.tools.dotc.core.Flags._
1111
import dotty.tools.dotc.core.Names.{Name, TermName}
1212
import dotty.tools.dotc.core.NameKinds.SimpleNameKind
1313
import dotty.tools.dotc.core.NameOps._
14+
import dotty.tools.dotc.core.Scopes._
1415
import dotty.tools.dotc.core.Symbols.{Symbol, defn}
1516
import dotty.tools.dotc.core.StdNames.nme
1617
import dotty.tools.dotc.core.SymDenotations.SymDenotation
@@ -185,7 +186,7 @@ object Completion {
185186
.groupByName.foreach { (name, denots) =>
186187
addMapping(name, ScopedDenotations(denots, ctx))
187188
}
188-
else if ctx.scope != null then
189+
else if ctx.scope ne EmptyScope then
189190
ctx.scope.toList.filter(symbol => include(symbol, symbol.name))
190191
.flatMap(_.alternatives)
191192
.groupByName.foreach { (name, denots) =>

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
324324
(prevPrec.ordinal < prec.ordinal || prevPrec == prec && (prevCtx.scope eq ctx.scope))
325325

326326
@tailrec def loop(lastCtx: Context)(using Context): Type =
327-
// Can ctx.scope actually be null?
328-
if ((ctx.scope: Scope | Null) == null) previous
327+
if (ctx.scope eq EmptyScope) previous
329328
else {
330329
var result: Type = NoType
331330

0 commit comments

Comments
 (0)