@@ -2,7 +2,7 @@ package dotty.tools
2
2
package dotc
3
3
package core
4
4
5
- // import scala.language.{unsafeNulls => _}
5
+ import scala .language .{unsafeNulls => _ }
6
6
7
7
import Periods ._ , Contexts ._ , Symbols ._ , Denotations ._ , Names ._ , NameOps ._ , Annotations ._
8
8
import Types ._ , Flags ._ , Decorators ._ , DenotTransformers ._ , StdNames ._ , Scopes ._
@@ -1723,14 +1723,14 @@ object SymDenotations {
1723
1723
myMemberCache = EqHashMap ()
1724
1724
myMemberCachePeriod = ctx.period
1725
1725
}
1726
- myMemberCache
1726
+ myMemberCache.nn
1727
1727
}
1728
1728
1729
1729
private def baseTypeCache (using Context ): BaseTypeMap = {
1730
1730
if ! currentHasSameBaseTypesAs(myBaseTypeCachePeriod) then
1731
1731
myBaseTypeCache = new BaseTypeMap ()
1732
1732
myBaseTypeCachePeriod = ctx.period
1733
- myBaseTypeCache
1733
+ myBaseTypeCache.nn
1734
1734
}
1735
1735
1736
1736
private def invalidateBaseDataCache () = {
@@ -1806,7 +1806,7 @@ object SymDenotations {
1806
1806
case _ => typeParamsFromDecls
1807
1807
}
1808
1808
}
1809
- myTypeParams
1809
+ myTypeParams.nn
1810
1810
}
1811
1811
1812
1812
override protected [dotc] final def info_= (tp : Type ): Unit = {
@@ -1841,7 +1841,7 @@ object SymDenotations {
1841
1841
1842
1842
// ------ class-specific operations -----------------------------------
1843
1843
1844
- private var myThisType : Type = null
1844
+ private var myThisType : Type | Null = null
1845
1845
1846
1846
/** The this-type depends on the kind of class:
1847
1847
* - for a package class `p`: ThisType(TypeRef(Noprefix, p))
@@ -1850,7 +1850,7 @@ object SymDenotations {
1850
1850
*/
1851
1851
override def thisType (using Context ): Type = {
1852
1852
if (myThisType == null ) myThisType = computeThisType
1853
- myThisType
1853
+ myThisType.nn
1854
1854
}
1855
1855
1856
1856
private def computeThisType (using Context ): Type = {
@@ -1859,11 +1859,11 @@ object SymDenotations {
1859
1859
ThisType .raw(TypeRef (pre, cls))
1860
1860
}
1861
1861
1862
- private var myTypeRef : TypeRef = null
1862
+ private var myTypeRef : TypeRef | Null = null
1863
1863
1864
1864
override def typeRef (using Context ): TypeRef = {
1865
1865
if (myTypeRef == null ) myTypeRef = super .typeRef
1866
- myTypeRef
1866
+ myTypeRef.nn
1867
1867
}
1868
1868
1869
1869
override def appliedRef (using Context ): Type = classInfo.appliedRef
@@ -1971,7 +1971,7 @@ object SymDenotations {
1971
1971
*/
1972
1972
def replace (prev : Symbol , replacement : Symbol )(using Context ): Unit = {
1973
1973
unforcedDecls.openForMutations.replace(prev, replacement)
1974
- if (myMemberCache != null ) myMemberCache.remove(replacement.name)
1974
+ if (myMemberCache != null ) myMemberCache.uncheckedNN. remove(replacement.name)
1975
1975
}
1976
1976
1977
1977
/** Delete symbol from current scope.
@@ -1982,7 +1982,7 @@ object SymDenotations {
1982
1982
val scope = info.decls.openForMutations
1983
1983
scope.unlink(sym, sym.name)
1984
1984
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)
1986
1986
if (! sym.flagsUNSAFE.is(Private )) invalidateMemberNamesCache()
1987
1987
}
1988
1988
@@ -2008,7 +2008,7 @@ object SymDenotations {
2008
2008
final def membersNamed (name : Name )(using Context ): PreDenotation =
2009
2009
Stats .record(" membersNamed" )
2010
2010
if Config .cacheMembersNamed then
2011
- var denots : PreDenotation = memberCache.lookup(name)
2011
+ var denots : PreDenotation | Null = memberCache.lookup(name)
2012
2012
if denots == null then
2013
2013
denots = computeMembersNamed(name)
2014
2014
memberCache(name) = denots
@@ -2416,7 +2416,7 @@ object SymDenotations {
2416
2416
)
2417
2417
if compiledNow.exists then compiledNow
2418
2418
else
2419
- val assocFiles = multi.aggregate(d => Set (d.symbol.associatedFile), _ union _)
2419
+ val assocFiles = multi.aggregate(d => Set (d.symbol.associatedFile.nn ), _ union _)
2420
2420
if assocFiles.size == 1 then
2421
2421
multi // they are all overloaded variants from the same file
2422
2422
else
@@ -2441,7 +2441,7 @@ object SymDenotations {
2441
2441
try f.container == chosen.container catch case NonFatal (ex) => true
2442
2442
if ! ambiguityWarningIssued then
2443
2443
for conflicting <- assocFiles.find(! sameContainer(_)) do
2444
- report.warning(i """ ${ambiguousFilesMsg(conflicting)}
2444
+ report.warning(i """ ${ambiguousFilesMsg(conflicting.nn )}
2445
2445
|Keeping only the definition in $chosen""" )
2446
2446
ambiguityWarningIssued = true
2447
2447
multi.filterWithPredicate(_.symbol.associatedFile == chosen)
@@ -2631,8 +2631,8 @@ object SymDenotations {
2631
2631
def apply (module : TermSymbol , modcls : ClassSymbol ): LazyType = this
2632
2632
2633
2633
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
2636
2636
private var mySourceModuleFn : Context ?=> Symbol = LazyType .NoSymbolFn
2637
2637
private var myModuleClassFn : Context ?=> Symbol = LazyType .NoSymbolFn
2638
2638
@@ -2644,10 +2644,10 @@ object SymDenotations {
2644
2644
def decls : Scope = myDecls
2645
2645
def sourceModule (using Context ): Symbol =
2646
2646
if mySourceModule == null then mySourceModule = mySourceModuleFn
2647
- mySourceModule
2647
+ mySourceModule.nn
2648
2648
def moduleClass (using Context ): Symbol =
2649
2649
if myModuleClass == null then myModuleClass = myModuleClassFn
2650
- myModuleClass
2650
+ myModuleClass.nn
2651
2651
2652
2652
def withDecls (decls : Scope ): this .type = { myDecls = decls; this }
2653
2653
def withSourceModule (sourceModuleFn : Context ?=> Symbol ): this .type = { mySourceModuleFn = sourceModuleFn; this }
@@ -2771,10 +2771,11 @@ object SymDenotations {
2771
2771
private abstract class InheritedCacheImpl (val createdAt : Period ) extends InheritedCache {
2772
2772
protected def sameGroup (p1 : Phase , p2 : Phase ): Boolean
2773
2773
2774
- private var dependent : WeakHashMap [InheritedCache , Unit ] = null
2774
+ private var dependent : WeakHashMap [InheritedCache , Unit ] | Null = null
2775
2775
private var checkedPeriod : Period = Nowhere
2776
2776
2777
2777
protected def invalidateDependents () = {
2778
+ import scala .language .unsafeNulls
2778
2779
if (dependent != null ) {
2779
2780
val it = dependent.keySet.iterator()
2780
2781
while (it.hasNext()) it.next().invalidate()
@@ -2784,7 +2785,7 @@ object SymDenotations {
2784
2785
2785
2786
protected def addDependent (dep : InheritedCache ) = {
2786
2787
if (dependent == null ) dependent = new WeakHashMap
2787
- dependent.put(dep, ())
2788
+ dependent.nn. put(dep, ())
2788
2789
}
2789
2790
2790
2791
def isValidAt (phase : Phase )(using Context ) =
@@ -2802,7 +2803,7 @@ object SymDenotations {
2802
2803
}
2803
2804
2804
2805
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
2806
2807
2807
2808
final def isValid (using Context ): Boolean =
2808
2809
cache != null && isValidAt(ctx.phase)
@@ -2823,15 +2824,15 @@ object SymDenotations {
2823
2824
2824
2825
def apply (keepOnly : NameFilter , clsd : ClassDenotation )(implicit onBehalf : MemberNames , ctx : Context ) = {
2825
2826
assert(isValid)
2826
- val cached = cache(keepOnly)
2827
+ val cached = cache.nn (keepOnly)
2827
2828
try
2828
2829
if (cached != null ) cached
2829
2830
else {
2830
2831
locked = true
2831
2832
val computed =
2832
2833
try clsd.computeMemberNames(keepOnly)(this , ctx)
2833
2834
finally locked = false
2834
- cache = cache.updated(keepOnly, computed)
2835
+ cache = cache.nn. updated(keepOnly, computed)
2835
2836
computed
2836
2837
}
2837
2838
finally addDependent(onBehalf)
@@ -2841,7 +2842,7 @@ object SymDenotations {
2841
2842
}
2842
2843
2843
2844
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
2845
2846
2846
2847
private var valid = true
2847
2848
private var locked = false
@@ -2866,7 +2867,7 @@ object SymDenotations {
2866
2867
: (List [ClassSymbol ], BaseClassSet ) = {
2867
2868
assert(isValid)
2868
2869
try
2869
- if (cache != null ) cache
2870
+ if (cache != null ) cache.uncheckedNN
2870
2871
else {
2871
2872
if (locked) throw CyclicReference (clsd)
2872
2873
locked = true
0 commit comments