@@ -2,7 +2,7 @@ package dotty.tools
22package dotc
33package core
44
5- // import scala.language.{unsafeNulls => _}
5+ import scala .language .{unsafeNulls => _ }
66
77import Periods ._ , Contexts ._ , Symbols ._ , Denotations ._ , Names ._ , NameOps ._ , Annotations ._
88import Types ._ , Flags ._ , Decorators ._ , DenotTransformers ._ , StdNames ._ , Scopes ._
@@ -1723,14 +1723,14 @@ object SymDenotations {
17231723 myMemberCache = EqHashMap ()
17241724 myMemberCachePeriod = ctx.period
17251725 }
1726- myMemberCache
1726+ myMemberCache.nn
17271727 }
17281728
17291729 private def baseTypeCache (using Context ): BaseTypeMap = {
17301730 if ! currentHasSameBaseTypesAs(myBaseTypeCachePeriod) then
17311731 myBaseTypeCache = new BaseTypeMap ()
17321732 myBaseTypeCachePeriod = ctx.period
1733- myBaseTypeCache
1733+ myBaseTypeCache.nn
17341734 }
17351735
17361736 private def invalidateBaseDataCache () = {
@@ -1806,7 +1806,7 @@ object SymDenotations {
18061806 case _ => typeParamsFromDecls
18071807 }
18081808 }
1809- myTypeParams
1809+ myTypeParams.nn
18101810 }
18111811
18121812 override protected [dotc] final def info_= (tp : Type ): Unit = {
@@ -1841,7 +1841,7 @@ object SymDenotations {
18411841
18421842 // ------ class-specific operations -----------------------------------
18431843
1844- private var myThisType : Type = null
1844+ private var myThisType : Type | Null = null
18451845
18461846 /** The this-type depends on the kind of class:
18471847 * - for a package class `p`: ThisType(TypeRef(Noprefix, p))
@@ -1850,7 +1850,7 @@ object SymDenotations {
18501850 */
18511851 override def thisType (using Context ): Type = {
18521852 if (myThisType == null ) myThisType = computeThisType
1853- myThisType
1853+ myThisType.nn
18541854 }
18551855
18561856 private def computeThisType (using Context ): Type = {
@@ -1859,11 +1859,11 @@ object SymDenotations {
18591859 ThisType .raw(TypeRef (pre, cls))
18601860 }
18611861
1862- private var myTypeRef : TypeRef = null
1862+ private var myTypeRef : TypeRef | Null = null
18631863
18641864 override def typeRef (using Context ): TypeRef = {
18651865 if (myTypeRef == null ) myTypeRef = super .typeRef
1866- myTypeRef
1866+ myTypeRef.nn
18671867 }
18681868
18691869 override def appliedRef (using Context ): Type = classInfo.appliedRef
@@ -1971,7 +1971,7 @@ object SymDenotations {
19711971 */
19721972 def replace (prev : Symbol , replacement : Symbol )(using Context ): Unit = {
19731973 unforcedDecls.openForMutations.replace(prev, replacement)
1974- if (myMemberCache != null ) myMemberCache.remove(replacement.name)
1974+ if (myMemberCache != null ) myMemberCache.uncheckedNN. remove(replacement.name)
19751975 }
19761976
19771977 /** Delete symbol from current scope.
@@ -1982,7 +1982,7 @@ object SymDenotations {
19821982 val scope = info.decls.openForMutations
19831983 scope.unlink(sym, sym.name)
19841984 if sym.name != sym.originalName then scope.unlink(sym, sym.originalName)
1985- if (myMemberCache != null ) myMemberCache.remove(sym.name)
1985+ if (myMemberCache != null ) myMemberCache.uncheckedNN. remove(sym.name)
19861986 if (! sym.flagsUNSAFE.is(Private )) invalidateMemberNamesCache()
19871987 }
19881988
@@ -2008,7 +2008,7 @@ object SymDenotations {
20082008 final def membersNamed (name : Name )(using Context ): PreDenotation =
20092009 Stats .record(" membersNamed" )
20102010 if Config .cacheMembersNamed then
2011- var denots : PreDenotation = memberCache.lookup(name)
2011+ var denots : PreDenotation | Null = memberCache.lookup(name)
20122012 if denots == null then
20132013 denots = computeMembersNamed(name)
20142014 memberCache(name) = denots
@@ -2416,7 +2416,7 @@ object SymDenotations {
24162416 )
24172417 if compiledNow.exists then compiledNow
24182418 else
2419- val assocFiles = multi.aggregate(d => Set (d.symbol.associatedFile), _ union _)
2419+ val assocFiles = multi.aggregate(d => Set (d.symbol.associatedFile.nn ), _ union _)
24202420 if assocFiles.size == 1 then
24212421 multi // they are all overloaded variants from the same file
24222422 else
@@ -2441,7 +2441,7 @@ object SymDenotations {
24412441 try f.container == chosen.container catch case NonFatal (ex) => true
24422442 if ! ambiguityWarningIssued then
24432443 for conflicting <- assocFiles.find(! sameContainer(_)) do
2444- report.warning(i """ ${ambiguousFilesMsg(conflicting)}
2444+ report.warning(i """ ${ambiguousFilesMsg(conflicting.nn )}
24452445 |Keeping only the definition in $chosen""" )
24462446 ambiguityWarningIssued = true
24472447 multi.filterWithPredicate(_.symbol.associatedFile == chosen)
@@ -2631,8 +2631,8 @@ object SymDenotations {
26312631 def apply (module : TermSymbol , modcls : ClassSymbol ): LazyType = this
26322632
26332633 private var myDecls : Scope = EmptyScope
2634- private var mySourceModule : Symbol = null
2635- private var myModuleClass : Symbol = null
2634+ private var mySourceModule : Symbol | Null = null
2635+ private var myModuleClass : Symbol | Null = null
26362636 private var mySourceModuleFn : Context ?=> Symbol = LazyType .NoSymbolFn
26372637 private var myModuleClassFn : Context ?=> Symbol = LazyType .NoSymbolFn
26382638
@@ -2644,10 +2644,10 @@ object SymDenotations {
26442644 def decls : Scope = myDecls
26452645 def sourceModule (using Context ): Symbol =
26462646 if mySourceModule == null then mySourceModule = mySourceModuleFn
2647- mySourceModule
2647+ mySourceModule.nn
26482648 def moduleClass (using Context ): Symbol =
26492649 if myModuleClass == null then myModuleClass = myModuleClassFn
2650- myModuleClass
2650+ myModuleClass.nn
26512651
26522652 def withDecls (decls : Scope ): this .type = { myDecls = decls; this }
26532653 def withSourceModule (sourceModuleFn : Context ?=> Symbol ): this .type = { mySourceModuleFn = sourceModuleFn; this }
@@ -2771,10 +2771,11 @@ object SymDenotations {
27712771 private abstract class InheritedCacheImpl (val createdAt : Period ) extends InheritedCache {
27722772 protected def sameGroup (p1 : Phase , p2 : Phase ): Boolean
27732773
2774- private var dependent : WeakHashMap [InheritedCache , Unit ] = null
2774+ private var dependent : WeakHashMap [InheritedCache , Unit ] | Null = null
27752775 private var checkedPeriod : Period = Nowhere
27762776
27772777 protected def invalidateDependents () = {
2778+ import scala .language .unsafeNulls
27782779 if (dependent != null ) {
27792780 val it = dependent.keySet.iterator()
27802781 while (it.hasNext()) it.next().invalidate()
@@ -2784,7 +2785,7 @@ object SymDenotations {
27842785
27852786 protected def addDependent (dep : InheritedCache ) = {
27862787 if (dependent == null ) dependent = new WeakHashMap
2787- dependent.put(dep, ())
2788+ dependent.nn. put(dep, ())
27882789 }
27892790
27902791 def isValidAt (phase : Phase )(using Context ) =
@@ -2802,7 +2803,7 @@ object SymDenotations {
28022803 }
28032804
28042805 private class MemberNamesImpl (createdAt : Period ) extends InheritedCacheImpl (createdAt) with MemberNames {
2805- private var cache : SimpleIdentityMap [NameFilter , Set [Name ]] = SimpleIdentityMap .empty
2806+ private var cache : SimpleIdentityMap [NameFilter , Set [Name ]] | Null = SimpleIdentityMap .empty
28062807
28072808 final def isValid (using Context ): Boolean =
28082809 cache != null && isValidAt(ctx.phase)
@@ -2823,15 +2824,15 @@ object SymDenotations {
28232824
28242825 def apply (keepOnly : NameFilter , clsd : ClassDenotation )(implicit onBehalf : MemberNames , ctx : Context ) = {
28252826 assert(isValid)
2826- val cached = cache(keepOnly)
2827+ val cached = cache.nn (keepOnly)
28272828 try
28282829 if (cached != null ) cached
28292830 else {
28302831 locked = true
28312832 val computed =
28322833 try clsd.computeMemberNames(keepOnly)(this , ctx)
28332834 finally locked = false
2834- cache = cache.updated(keepOnly, computed)
2835+ cache = cache.nn. updated(keepOnly, computed)
28352836 computed
28362837 }
28372838 finally addDependent(onBehalf)
@@ -2841,7 +2842,7 @@ object SymDenotations {
28412842 }
28422843
28432844 private class BaseDataImpl (createdAt : Period ) extends InheritedCacheImpl (createdAt) with BaseData {
2844- private var cache : (List [ClassSymbol ], BaseClassSet ) = null
2845+ private var cache : (List [ClassSymbol ], BaseClassSet ) | Null = null
28452846
28462847 private var valid = true
28472848 private var locked = false
@@ -2866,7 +2867,7 @@ object SymDenotations {
28662867 : (List [ClassSymbol ], BaseClassSet ) = {
28672868 assert(isValid)
28682869 try
2869- if (cache != null ) cache
2870+ if (cache != null ) cache.uncheckedNN
28702871 else {
28712872 if (locked) throw CyclicReference (clsd)
28722873 locked = true
0 commit comments