@@ -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 }
@@ -105,13 +107,13 @@ object Implicits:
105107 */
106108 def companionRefs : TermRefSet = TermRefSet .empty
107109
108- private var mySingletonClass : ClassSymbol = null
110+ private var mySingletonClass : ClassSymbol | Null = null
109111
110112 /** Widen type so that it is neither a singleton type nor a type that inherits from scala.Singleton. */
111113 private def widenSingleton (tp : Type )(using Context ): Type = {
112114 if (mySingletonClass == null ) mySingletonClass = defn.SingletonClass
113115 val wtp = tp.widenSingleton
114- if (wtp.derivesFrom(mySingletonClass)) defn.AnyType else wtp
116+ if (wtp.derivesFrom(mySingletonClass.uncheckedNN )) defn.AnyType else wtp
115117 }
116118
117119 protected def isAccessible (ref : TermRef )(using Context ): Boolean
@@ -272,7 +274,7 @@ object Implicits:
272274 * @param companionRefs the companion objects in the implicit scope.
273275 */
274276 class OfTypeImplicits (tp : Type , override val companionRefs : TermRefSet )(initctx : Context ) extends ImplicitRefs (initctx) {
275- assert(initctx.typer != null )
277+ // assert(initctx.typer != null)
276278 implicits.println(i " implicit scope of type $tp = ${companionRefs.showAsList}%, % " )
277279 @ threadUnsafe lazy val refs : List [ImplicitRef ] = {
278280 val buf = new mutable.ListBuffer [TermRef ]
@@ -312,23 +314,23 @@ object Implicits:
312314 * Scala2 mode, since we do not want to change the implicit disambiguation then.
313315 */
314316 override val level : Int =
315- def isSameOwner = irefCtx.owner eq outerImplicits.irefCtx.owner
316- def isSameScope = irefCtx.scope eq outerImplicits.irefCtx.scope
317+ def isSameOwner = irefCtx.owner eq outerImplicits.uncheckedNN. irefCtx.owner
318+ def isSameScope = irefCtx.scope eq outerImplicits.uncheckedNN. irefCtx.scope
317319 def isLazyImplicit = refs.head.implicitName.is(LazyImplicitName )
318320
319321 if outerImplicits == null then 1
320322 else if migrateTo3(using irefCtx)
321323 || isSameOwner && (isImport || isSameScope && ! isLazyImplicit)
322- then outerImplicits.level
323- else outerImplicits.level + 1
324+ then outerImplicits.uncheckedNN. level
325+ else outerImplicits.uncheckedNN. level + 1
324326 end level
325327
326328 /** Is this the outermost implicits? This is the case if it either the implicits
327329 * of NoContext, or the last one before it.
328330 */
329331 private def isOuterMost = {
330332 val finalImplicits = NoContext .implicits
331- (this eq finalImplicits) || (outerImplicits eq finalImplicits)
333+ (this eq finalImplicits) || (outerImplicits eqn finalImplicits)
332334 }
333335
334336 private def combineEligibles (ownEligible : List [Candidate ], outerEligible : List [Candidate ]): List [Candidate ] =
@@ -370,7 +372,7 @@ object Implicits:
370372 if (monitored) record(s " check eligible refs in irefCtx " , refs.length)
371373 val ownEligible = filterMatching(tp)
372374 if isOuterMost then ownEligible
373- else combineEligibles(ownEligible, outerImplicits.eligible(tp))
375+ else combineEligibles(ownEligible, outerImplicits.uncheckedNN. eligible(tp))
374376 }
375377
376378 override def isAccessible (ref : TermRef )(using Context ): Boolean =
@@ -387,9 +389,9 @@ object Implicits:
387389 def exclude (root : Symbol ): ContextualImplicits =
388390 if (this == NoContext .implicits) this
389391 else {
390- val outerExcluded = outerImplicits exclude root
392+ val outerExcluded = outerImplicits.uncheckedNN exclude root
391393 if (irefCtx.importInfo.site.termSymbol == root) outerExcluded
392- else if (outerExcluded eq outerImplicits) this
394+ else if (outerExcluded eqn outerImplicits) this
393395 else new ContextualImplicits (refs, outerExcluded, isImport)(irefCtx)
394396 }
395397 }
@@ -848,7 +850,7 @@ trait Implicits:
848850 }
849851 }
850852
851- private var synthesizer : Synthesizer = null
853+ private var synthesizer : Synthesizer | Null = null
852854
853855 /** Find an implicit argument for parameter `formal`.
854856 * Return a failure as a SearchFailureType in the type of the returned tree.
@@ -860,7 +862,7 @@ trait Implicits:
860862 if fail.isAmbiguous then failed
861863 else
862864 if synthesizer == null then synthesizer = Synthesizer (this )
863- synthesizer.tryAll(formal, span).orElse(failed)
865+ synthesizer.uncheckedNN. tryAll(formal, span).orElse(failed)
864866
865867 /** Search an implicit argument and report error if not found */
866868 def implicitArgTree (formal : Type , span : Span )(using Context ): Tree = {
@@ -1678,11 +1680,11 @@ final class SearchRoot extends SearchHistory:
16781680 var nestedSearches : Int = 0
16791681
16801682 /** The dictionary of recursive implicit types and corresponding terms for this search. */
1681- var myImplicitDictionary : mutable.Map [Type , (TermRef , tpd.Tree )] = null
1683+ var myImplicitDictionary : mutable.Map [Type , (TermRef , tpd.Tree )] | Null = null
16821684 private def implicitDictionary =
16831685 if myImplicitDictionary == null then
16841686 myImplicitDictionary = mutable.Map .empty[Type , (TermRef , tpd.Tree )]
1685- myImplicitDictionary
1687+ myImplicitDictionary.uncheckedNN
16861688
16871689 /**
16881690 * Link a reference to an under-construction implicit for the provided type to its
@@ -1861,10 +1863,12 @@ sealed class TermRefSet(using Context):
18611863 if ! that.isEmpty then that.foreach(+= )
18621864
18631865 def foreach [U ](f : TermRef => U ): Unit =
1864- elems.forEach((sym : TermSymbol , prefixes : Type | List [Type ]) =>
1866+ // TODO
1867+ def handle (sym : TermSymbol | Null , prefixes : Type | List [Type ] | Null ): Unit =
18651868 prefixes match
1866- case prefix : Type => f(TermRef (prefix, sym))
1867- case prefixes : List [Type ] => prefixes.foreach(pre => f(TermRef (pre, sym))))
1869+ case prefix : Type => f(TermRef (prefix, sym.uncheckedNN))
1870+ case prefixes : List [Type ] => prefixes.foreach(pre => f(TermRef (pre, sym.uncheckedNN)))
1871+ elems.forEach(handle)
18681872
18691873 // used only for debugging
18701874 def showAsList : List [TermRef ] = {
0 commit comments