@@ -2,6 +2,8 @@ package dotty.tools
22package dotc
33package typer
44
5+ import scala .language .{unsafeNulls => _ }
6+
57import backend .sjs .JSDefinitions
68import core ._
79import ast .{Trees , TreeTypeMap , untpd , tpd , DesugarEnums }
@@ -104,13 +106,13 @@ object Implicits:
104106 */
105107 def companionRefs : TermRefSet = TermRefSet .empty
106108
107- private var mySingletonClass : ClassSymbol = null
109+ private var mySingletonClass : ClassSymbol | Null = null
108110
109111 /** Widen type so that it is neither a singleton type nor a type that inherits from scala.Singleton. */
110112 private def widenSingleton (tp : Type )(using Context ): Type = {
111113 if (mySingletonClass == null ) mySingletonClass = defn.SingletonClass
112114 val wtp = tp.widenSingleton
113- if (wtp.derivesFrom(mySingletonClass)) defn.AnyType else wtp
115+ if (wtp.derivesFrom(mySingletonClass.uncheckedNN )) defn.AnyType else wtp
114116 }
115117
116118 protected def isAccessible (ref : TermRef )(using Context ): Boolean
@@ -271,7 +273,7 @@ object Implicits:
271273 * @param companionRefs the companion objects in the implicit scope.
272274 */
273275 class OfTypeImplicits (tp : Type , override val companionRefs : TermRefSet )(initctx : Context ) extends ImplicitRefs (initctx) {
274- assert(initctx.typer != null )
276+ // assert(initctx.typer != null)
275277 implicits.println(i " implicit scope of type $tp = ${companionRefs.showAsList}%, % " )
276278 @ threadUnsafe lazy val refs : List [ImplicitRef ] = {
277279 val buf = new mutable.ListBuffer [TermRef ]
@@ -311,23 +313,23 @@ object Implicits:
311313 * Scala2 mode, since we do not want to change the implicit disambiguation then.
312314 */
313315 override val level : Int =
314- def isSameOwner = irefCtx.owner eq outerImplicits.irefCtx.owner
315- def isSameScope = irefCtx.scope eq outerImplicits.irefCtx.scope
316+ def isSameOwner = irefCtx.owner eq outerImplicits.uncheckedNN. irefCtx.owner
317+ def isSameScope = irefCtx.scope eq outerImplicits.uncheckedNN. irefCtx.scope
316318 def isLazyImplicit = refs.head.implicitName.is(LazyImplicitName )
317319
318320 if outerImplicits == null then 1
319321 else if migrateTo3(using irefCtx)
320322 || isSameOwner && (isImport || isSameScope && ! isLazyImplicit)
321- then outerImplicits.level
322- else outerImplicits.level + 1
323+ then outerImplicits.uncheckedNN. level
324+ else outerImplicits.uncheckedNN. level + 1
323325 end level
324326
325327 /** Is this the outermost implicits? This is the case if it either the implicits
326328 * of NoContext, or the last one before it.
327329 */
328330 private def isOuterMost = {
329331 val finalImplicits = NoContext .implicits
330- (this eq finalImplicits) || (outerImplicits eq finalImplicits)
332+ (this eq finalImplicits) || (outerImplicits eqn finalImplicits)
331333 }
332334
333335 private def combineEligibles (ownEligible : List [Candidate ], outerEligible : List [Candidate ]): List [Candidate ] =
@@ -369,7 +371,7 @@ object Implicits:
369371 if (monitored) record(s " check eligible refs in irefCtx " , refs.length)
370372 val ownEligible = filterMatching(tp)
371373 if isOuterMost then ownEligible
372- else combineEligibles(ownEligible, outerImplicits.eligible(tp))
374+ else combineEligibles(ownEligible, outerImplicits.uncheckedNN. eligible(tp))
373375 }
374376
375377 override def isAccessible (ref : TermRef )(using Context ): Boolean =
@@ -386,9 +388,9 @@ object Implicits:
386388 def exclude (root : Symbol ): ContextualImplicits =
387389 if (this == NoContext .implicits) this
388390 else {
389- val outerExcluded = outerImplicits exclude root
391+ val outerExcluded = outerImplicits.uncheckedNN exclude root
390392 if (irefCtx.importInfo.site.termSymbol == root) outerExcluded
391- else if (outerExcluded eq outerImplicits) this
393+ else if (outerExcluded eqn outerImplicits) this
392394 else new ContextualImplicits (refs, outerExcluded, isImport)(irefCtx)
393395 }
394396 }
@@ -841,7 +843,7 @@ trait Implicits:
841843 }
842844 }
843845
844- private var synthesizer : Synthesizer = null
846+ private var synthesizer : Synthesizer | Null = null
845847
846848 /** Find an implicit argument for parameter `formal`.
847849 * Return a failure as a SearchFailureType in the type of the returned tree.
@@ -853,7 +855,7 @@ trait Implicits:
853855 if fail.isAmbiguous then failed
854856 else
855857 if synthesizer == null then synthesizer = Synthesizer (this )
856- synthesizer.tryAll(formal, span).orElse(failed)
858+ synthesizer.uncheckedNN. tryAll(formal, span).orElse(failed)
857859
858860 /** Search an implicit argument and report error if not found */
859861 def implicitArgTree (formal : Type , span : Span )(using Context ): Tree = {
@@ -1666,11 +1668,11 @@ final class SearchRoot extends SearchHistory:
16661668 var nestedSearches : Int = 0
16671669
16681670 /** The dictionary of recursive implicit types and corresponding terms for this search. */
1669- var myImplicitDictionary : mutable.Map [Type , (TermRef , tpd.Tree )] = null
1671+ var myImplicitDictionary : mutable.Map [Type , (TermRef , tpd.Tree )] | Null = null
16701672 private def implicitDictionary =
16711673 if myImplicitDictionary == null then
16721674 myImplicitDictionary = mutable.Map .empty[Type , (TermRef , tpd.Tree )]
1673- myImplicitDictionary
1675+ myImplicitDictionary.uncheckedNN
16741676
16751677 /**
16761678 * Link a reference to an under-construction implicit for the provided type to its
@@ -1849,10 +1851,12 @@ sealed class TermRefSet(using Context):
18491851 if ! that.isEmpty then that.foreach(+= )
18501852
18511853 def foreach [U ](f : TermRef => U ): Unit =
1852- elems.forEach((sym : TermSymbol , prefixes : Type | List [Type ]) =>
1854+ // TODO
1855+ def handle (sym : TermSymbol | Null , prefixes : Type | List [Type ] | Null ): Unit =
18531856 prefixes match
1854- case prefix : Type => f(TermRef (prefix, sym))
1855- case prefixes : List [Type ] => prefixes.foreach(pre => f(TermRef (pre, sym))))
1857+ case prefix : Type => f(TermRef (prefix, sym.uncheckedNN))
1858+ case prefixes : List [Type ] => prefixes.foreach(pre => f(TermRef (pre, sym.uncheckedNN)))
1859+ elems.forEach(handle)
18561860
18571861 // used only for debugging
18581862 def showAsList : List [TermRef ] = {
0 commit comments