@@ -2,7 +2,7 @@ package dotty.tools
22package dotc
33package core
44
5- // import scala.language.{unsafeNulls => _}
5+ import scala .language .{unsafeNulls => _ }
66
77import scala .io .Codec
88import util .NameTransformer
@@ -167,15 +167,15 @@ object Names {
167167 override def asTermName : TermName = this
168168
169169 @ sharable // because it is only modified in the synchronized block of toTypeName.
170- private var myTypeName : TypeName = null
170+ private var myTypeName : TypeName | Null = null
171171 // Note: no @volatile needed since type names are immutable and therefore safely published
172172
173173 override def toTypeName : TypeName =
174174 if myTypeName == null then
175175 synchronized {
176176 if myTypeName == null then myTypeName = new TypeName (this )
177177 }
178- myTypeName
178+ myTypeName.nn
179179
180180 override def likeSpaced (name : Name ): TermName = name.toTermName
181181
@@ -191,7 +191,7 @@ object Names {
191191 val derivedName = new DerivedName (this , info)
192192 derivedNames = derivedNames.updated(info, derivedName)
193193 derivedName
194- case derivedName =>
194+ case derivedName : DerivedName =>
195195 derivedName
196196 }
197197
@@ -229,10 +229,10 @@ object Names {
229229 }
230230
231231 @ sharable // because it's just a cache for performance
232- private var myMangledString : String = null
232+ private var myMangledString : String | Null = null
233233
234234 @ sharable // because it's just a cache for performance
235- private var myMangled : Name = null
235+ private var myMangled : Name | Null = null
236236
237237 protected [Names ] def mangle : ThisName
238238
@@ -244,7 +244,7 @@ object Names {
244244 final def mangledString : String = {
245245 if (myMangledString == null )
246246 myMangledString = qualToString(_.mangledString, _.mangled.toString)
247- myMangledString
247+ myMangledString.nn
248248 }
249249
250250 /** If this a qualified name, split it into underlying, last part, and separator
@@ -263,11 +263,11 @@ object Names {
263263
264264 protected def computeToString : String
265265
266- @ sharable private var myToString : String = null
266+ @ sharable private var myToString : String | Null = null
267267
268- override def toString =
268+ override def toString : String =
269269 if myToString == null then myToString = computeToString
270- myToString
270+ myToString.nn
271271
272272 }
273273
@@ -390,7 +390,7 @@ object Names {
390390 // because asserts are caught in exception handlers which might
391391 // cause other failures. In that case the first, important failure
392392 // is lost.
393- System .err.println(" Backend should not call Name#toString, Name#mangledString should be used instead." )
393+ System .err.nn. println(" Backend should not call Name#toString, Name#mangledString should be used instead." )
394394 Thread .dumpStack()
395395 assert(false )
396396 }
@@ -401,8 +401,8 @@ object Names {
401401 * from GenBCode or it also contains one of the whitelisted methods below.
402402 */
403403 private def toStringOK = {
404- val trace = Thread .currentThread.getStackTrace
405- ! trace.exists(_.getClassName.endsWith(" GenBCode" )) ||
404+ val trace : Array [ StackTraceElement ] = Thread .currentThread.nn. getStackTrace. asInstanceOf [ Array [ StackTraceElement ]]
405+ ! trace.exists(_.getClassName.nn. endsWith(" GenBCode" )) ||
406406 trace.exists(elem =>
407407 List (
408408 " mangledString" ,
@@ -546,10 +546,10 @@ object Names {
546546 Stats .record(statsItem(" put" ))
547547 val myTable = currentTable // could be outdated under parallel execution
548548 var idx = hashValue(cs, offset, len) & (myTable.length - 1 )
549- var name = myTable(idx).asInstanceOf [SimpleName ]
549+ var name = myTable(idx).asInstanceOf [SimpleName | Null ]
550550 while name != null do
551- if name.length == len && Names .equals(name.start, cs, offset, len) then
552- return name
551+ if name.nn. length == len && Names .equals(name.nn .start, cs, offset, len) then
552+ return name.nn
553553 Stats .record(statsItem(" miss" ))
554554 idx = (idx + 1 ) & (myTable.length - 1 )
555555 name = myTable(idx).asInstanceOf [SimpleName ]
@@ -567,7 +567,7 @@ object Names {
567567 ensureCapacity(nc + len)
568568 Array .copy(cs, offset, chrs, nc, len)
569569 nc += len
570- addEntryAt(idx, name)
570+ addEntryAt(idx, name.nn )
571571 else
572572 enterIfNew(cs, offset, len)
573573 }
@@ -630,10 +630,10 @@ object Names {
630630 * See `sliceToTermName` in `Decorators` for a more efficient version
631631 * which however requires a Context for its operation.
632632 */
633- def termName (s : String ): SimpleName = termName(s.toCharArray, 0 , s.length)
633+ def termName (s : String ): SimpleName = termName(s.toCharArray.nn , 0 , s.length)
634634
635635 /** Create a type name from a string */
636- def typeName (s : String ): TypeName = typeName(s.toCharArray, 0 , s.length)
636+ def typeName (s : String ): TypeName = typeName(s.toCharArray.nn , 0 , s.length)
637637
638638 /** The type name represented by the empty string */
639639 val EmptyTypeName : TypeName = EmptyTermName .toTypeName
0 commit comments