Skip to content

Commit e60dcbb

Browse files
committed
Remove more .nn
1 parent 1c19710 commit e60dcbb

33 files changed

+56
-71
lines changed

compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala

+6-8
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import BTypes.InternalName
1818
import scala.util.chaining.*
1919
import dotty.tools.io.JarArchive
2020

21-
import scala.language.unsafeNulls
22-
2321
/** !!! This file is now copied in `dotty.tools.io.FileWriters` in a more general way that does not rely upon
2422
* `PostProcessorFrontendAccess`, this should probably be changed to wrap that class instead.
2523
*
@@ -54,11 +52,11 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
5452
def close(): Unit
5553

5654
protected def classRelativePath(className: InternalName, suffix: String = ".class"): String =
57-
className.replace('.', '/').nn + suffix
55+
className.replace('.', '/') + suffix
5856
}
5957

6058
object ClassfileWriter {
61-
private def getDirectory(dir: String): Path = Paths.get(dir).nn
59+
private def getDirectory(dir: String): Path = Paths.get(dir)
6260

6361
def apply(): ClassfileWriter = {
6462
val jarManifestMainClass: Option[String] = compilerSettings.mainClass.orElse {
@@ -137,7 +135,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
137135
new JarEntryWriter(jarFile, jarManifestMainClass, jarCompressionLevel)
138136
}
139137
else if (file.isVirtual) new VirtualFileWriter(file)
140-
else if (file.isDirectory) new DirEntryWriter(file.file.toPath.nn)
138+
else if (file.isDirectory) new DirEntryWriter(file.file.toPath)
141139
else throw new IllegalStateException(s"don't know how to handle an output of $file [${file.getClass}]")
142140
}
143141

@@ -151,7 +149,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
151149
val jarWriter: JarOutputStream = {
152150
import scala.util.Properties.*
153151
val manifest = new Manifest
154-
val attrs = manifest.getMainAttributes.nn
152+
val attrs = manifest.getMainAttributes
155153
attrs.put(MANIFEST_VERSION, "1.0")
156154
attrs.put(ScalaCompilerVersion, versionNumberString)
157155
mainClass.foreach(c => attrs.put(MAIN_CLASS, c))
@@ -184,7 +182,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
184182
// important detail here, even on Windows, Zinc expects the separator within the jar
185183
// to be the system default, (even if in the actual jar file the entry always uses '/').
186184
// see https://github.com/sbt/zinc/blob/dcddc1f9cfe542d738582c43f4840e17c053ce81/internal/compiler-bridge/src/main/scala/xsbt/JarUtils.scala#L47
187-
val pathInJar =
185+
val pathInJar =
188186
if File.separatorChar == '/' then relativePath
189187
else relativePath.replace('/', File.separatorChar)
190188
PlainFile.toPlainFile(Paths.get(s"${file.absolutePath}!$pathInJar"))
@@ -293,5 +291,5 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) {
293291
}
294292

295293
/** Can't output a file due to the state of the file system. */
296-
class FileConflictException(msg: String, cause: Throwable = null) extends IOException(msg, cause)
294+
class FileConflictException(msg: String, cause: Throwable | Null = null) extends IOException(msg, cause)
297295
}

compiler/src/dotty/tools/dotc/Driver.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Driver {
3838
finish(compiler, run)
3939
catch
4040
case ex: FatalError =>
41-
report.error(ex.getMessage.nn) // signals that we should fail compilation.
41+
report.error(ex.getMessage) // signals that we should fail compilation.
4242
case ex: Throwable if ctx.usedBestEffortTasty =>
4343
report.bestEffortError(ex, "Some best-effort tasty files were not able to be read.")
4444
throw ex
@@ -117,7 +117,7 @@ class Driver {
117117
.distinct
118118
val ctx1 = ctx.fresh
119119
val fullClassPath =
120-
(newEntries :+ ctx.settings.classpath.value).mkString(java.io.File.pathSeparator.nn)
120+
(newEntries :+ ctx.settings.classpath.value).mkString(java.io.File.pathSeparator)
121121
ctx1.setSetting(ctx1.settings.classpath, fullClassPath)
122122
else ctx
123123

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ class CheckCaptures extends Recheck, SymTransformer:
963963
trace.force(i"rechecking $tree with pt = $pt", recheckr, show = true):
964964
super.recheck(tree, pt)
965965
catch case ex: NoCommonRoot =>
966-
report.error(ex.getMessage.nn)
966+
report.error(ex.getMessage)
967967
tree.tpe
968968
finally curEnv = saved
969969
if tree.isTerm then

compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ClassPathFactory {
6767
for
6868
file <- files
6969
a <- ClassPath.expandManifestPath(file.absolutePath)
70-
path = java.nio.file.Paths.get(a.toURI()).nn
70+
path = java.nio.file.Paths.get(a.toURI())
7171
if Files.exists(path)
7272
yield
7373
newClassPath(AbstractFile.getFile(path))

compiler/src/dotty/tools/dotc/config/CommandLineParser.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ object CommandLineParser:
118118
Nil
119119
else
120120
def stripComment(s: String) = s.indexOf('#') match { case -1 => s case i => s.substring(0, i) }
121-
val lines = Files.readAllLines(path).nn
122-
val params = lines.asScala.map(stripComment).filter(!_.nn.isEmpty).mkString(" ")
121+
val lines = Files.readAllLines(path)
122+
val params = lines.asScala.map(stripComment).filter(!_.isEmpty).mkString(" ")
123123
tokenize(params)
124124

125125
class ParseException(msg: String) extends RuntimeException(msg)

compiler/src/dotty/tools/dotc/core/Comments.scala

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package dotty.tools
22
package dotc
33
package core
44

5-
import scala.language.unsafeNulls
6-
75
import ast.{ untpd, tpd }
86
import Symbols.*, Contexts.*
97
import util.{SourceFile, ReadOnlyMap}

compiler/src/dotty/tools/dotc/core/Decorators.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object Decorators {
5151
if name.length != 0 then name.getChars(0, name.length, chars, s.length)
5252
termName(chars, 0, len)
5353
case name: TypeName => s.concat(name.toTermName)
54-
case _ => termName(s.concat(name.toString).nn)
54+
case _ => termName(s.concat(name.toString))
5555

5656
def indented(width: Int): String =
5757
val padding = " " * width
@@ -289,10 +289,10 @@ object Decorators {
289289
case NonFatal(ex)
290290
if !ctx.settings.YshowPrintErrors.value =>
291291
s"... (cannot display due to ${ex.className} ${ex.getMessage}) ..."
292-
case _ => String.valueOf(x).nn
292+
case _ => String.valueOf(x)
293293

294294
/** Returns the simple class name of `x`. */
295-
def className: String = x.getClass.getSimpleName.nn
295+
def className: String = x.getClass.getSimpleName
296296

297297
extension [T](x: T)
298298
def assertingErrorsReported(using Context): T = {

compiler/src/dotty/tools/dotc/core/NameOps.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import nme.*
1515
object NameOps {
1616

1717
object compactify {
18-
lazy val md5: MessageDigest = MessageDigest.getInstance("MD5").nn
18+
lazy val md5: MessageDigest = MessageDigest.getInstance("MD5")
1919

2020
inline val CLASSFILE_NAME_CHAR_LIMIT = 240
2121

@@ -43,7 +43,7 @@ object NameOps {
4343
val suffix = s.takeRight(edge)
4444

4545
val cs = s.toArray
46-
val bytes = Codec.toUTF8(CharBuffer.wrap(cs).nn)
46+
val bytes = Codec.toUTF8(CharBuffer.wrap(cs))
4747
md5.update(bytes)
4848
val md5chars = md5.digest().map(b => (b & 0xFF).toHexString).mkString
4949

compiler/src/dotty/tools/dotc/core/TypeErrors.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class TypeError(using creationContext: Context) extends Exception(""):
3232
|| ctx.settings.YdebugCyclic.value
3333

3434
override def fillInStackTrace(): Throwable =
35-
if computeStackTrace then super.fillInStackTrace().nn
35+
if computeStackTrace then super.fillInStackTrace()
3636
else this
3737

3838
/** Convert to message. This takes an additional Context, so that we

compiler/src/dotty/tools/dotc/core/TypeEval.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object TypeEval:
9494
val result =
9595
try op
9696
catch case e: Throwable =>
97-
throw TypeError(em"${e.getMessage.nn}")
97+
throw TypeError(em"${e.getMessage}")
9898
ConstantType(Constant(result))
9999

100100
def fieldsOf: Option[Type] =

compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dotty.tools.dotc
22
package core.tasty
33

4-
import scala.language.unsafeNulls
54
import scala.collection.immutable.BitSet
65
import scala.collection.immutable.TreeMap
76

compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object TastyPrinter:
5353
else if arg.endsWith(".tasty") || (allowBetasty && arg.endsWith(".betasty")) then
5454
val path = Paths.get(arg)
5555
if Files.exists(path) then
56-
printTasty(arg, Files.readAllBytes(path).nn, arg.endsWith(".betasty"))
56+
printTasty(arg, Files.readAllBytes(path), arg.endsWith(".betasty"))
5757
else
5858
println("File not found: " + arg)
5959
System.exit(1)

compiler/src/dotty/tools/dotc/plugins/Plugins.scala

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dotty.tools.dotc
22
package plugins
33

4-
import scala.language.unsafeNulls
5-
64
import core.*
75
import Contexts.*
86
import Decorators.em
@@ -47,13 +45,12 @@ trait Plugins {
4745
goods map (_.get)
4846
}
4947

50-
private var _roughPluginsList: List[Plugin] = uninitialized
48+
private var _roughPluginsList: List[Plugin] | Null = null
5149
protected def roughPluginsList(using Context): List[Plugin] =
5250
if (_roughPluginsList == null) {
5351
_roughPluginsList = loadRoughPluginsList
54-
_roughPluginsList
5552
}
56-
else _roughPluginsList
53+
_roughPluginsList.nn
5754

5855
/** Load all available plugins. Skips plugins that
5956
* either have the same name as another one, or which
@@ -99,13 +96,12 @@ trait Plugins {
9996
plugs
10097
}
10198

102-
private var _plugins: List[Plugin] = uninitialized
99+
private var _plugins: List[Plugin] | Null = null
103100
def plugins(using Context): List[Plugin] =
104101
if (_plugins == null) {
105102
_plugins = loadPlugins
106-
_plugins
107103
}
108-
else _plugins
104+
_plugins.nn
109105

110106
/** A description of all the plugins that are loaded */
111107
def pluginDescriptions(using Context): String =

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
394394
case tp: ThisType =>
395395
nameString(tp.cls) + ".this"
396396
case SuperType(thistpe: SingletonType, _) =>
397-
toTextRef(thistpe).map(_.replaceAll("""\bthis$""", "super").nn)
397+
toTextRef(thistpe).map(_.replaceAll("""\bthis$""", "super"))
398398
case SuperType(thistpe, _) =>
399399
"Super(" ~ toTextGlobal(thistpe) ~ ")"
400400
case tp @ ConstantType(value) =>
@@ -628,7 +628,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
628628
case '"' => "\\\""
629629
case '\'' => "\\\'"
630630
case '\\' => "\\\\"
631-
case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch).nn
631+
case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch)
632632
}
633633

634634
def toText(const: Constant): Text = const.tag match {
@@ -638,7 +638,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
638638
case LongTag => literalText(const.longValue.toString + "L")
639639
case DoubleTag => literalText(const.doubleValue.toString + "d")
640640
case FloatTag => literalText(const.floatValue.toString + "f")
641-
case _ => literalText(String.valueOf(const.value).nn)
641+
case _ => literalText(String.valueOf(const.value))
642642
}
643643

644644
/** Usual target for `Annotation#toText`, overridden in RefinedPrinter */

compiler/src/dotty/tools/dotc/printing/Showable.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait Showable extends Any {
2525
/** The string representation with each line after the first one indented
2626
* by the given given margin (in spaces).
2727
*/
28-
def showIndented(margin: Int)(using Context): String = show.replace("\n", "\n" + " " * margin).nn
28+
def showIndented(margin: Int)(using Context): String = show.replace("\n", "\n" + " " * margin)
2929

3030
/** The summarized string representation of this showable element.
3131
* Recursion depth is limited to some smallish value. Default is

compiler/src/dotty/tools/dotc/printing/Texts.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.annotation.internal.sharable
55
object Texts {
66

77
@sharable
8-
private val ansi = java.util.regex.Pattern.compile("\u001b\\[\\d+m").nn
8+
private val ansi = java.util.regex.Pattern.compile("\u001b\\[\\d+m")
99

1010
sealed abstract class Text {
1111

compiler/src/dotty/tools/dotc/quoted/Interpreter.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dotty.tools.dotc
22
package quoted
33

4-
import scala.language.unsafeNulls
5-
64
import scala.collection.mutable
75
import scala.reflect.ClassTag
86

compiler/src/dotty/tools/dotc/reporting/messages.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ abstract class CyclicMsg(errorId: ErrorMessageID)(using Context) extends Message
9292

9393
protected def debugInfo =
9494
if ctx.settings.YdebugCyclic.value then
95-
"\n\nStacktrace:" ++ ex.getStackTrace().nn.mkString("\n ", "\n ", "")
95+
"\n\nStacktrace:" ++ ex.getStackTrace().mkString("\n ", "\n ", "")
9696
else "\n\n Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace."
9797

9898
protected def context: String = ex.optTrace match

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ object Scala3:
420420
else Descriptor.None
421421

422422
def unescapeUnicode =
423-
unicodeEscape.replaceAllIn(symbol, m => String.valueOf(Integer.parseInt(m.group(1), 16).toChar).nn)
423+
unicodeEscape.replaceAllIn(symbol, m => String.valueOf(Integer.parseInt(m.group(1), 16).toChar))
424424

425425
def isJavaIdent =
426426
symbol.nonEmpty && isJavaIdentifierStart(symbol.head) && symbol.tail.forall(isJavaIdentifierPart)

compiler/src/dotty/tools/dotc/transform/Pickler.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class Pickler extends Phase {
258258
}
259259

260260
private def computeInternalName(cls: ClassSymbol)(using Context): String =
261-
if cls.is(Module) then cls.binaryClassName.stripSuffix(str.MODULE_SUFFIX).nn
261+
if cls.is(Module) then cls.binaryClassName.stripSuffix(str.MODULE_SUFFIX)
262262
else cls.binaryClassName
263263

264264
override def run(using Context): Unit = {
@@ -413,11 +413,11 @@ class Pickler extends Phase {
413413
)
414414
if ctx.isBestEffort then
415415
val outpath =
416-
ctx.settings.outputDir.value.jpath.toAbsolutePath.nn.normalize.nn
417-
.resolve("META-INF").nn
416+
ctx.settings.outputDir.value.jpath.toAbsolutePath.normalize
417+
.resolve("META-INF")
418418
.resolve("best-effort")
419419
Files.createDirectories(outpath)
420-
BestEffortTastyWriter.write(outpath.nn, result)
420+
BestEffortTastyWriter.write(outpath, result)
421421
result
422422
}
423423

compiler/src/dotty/tools/dotc/transform/init/Errors.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Errors:
3131
report.warning(show, this.pos)
3232
end Error
3333

34-
override def toString() = this.getClass.getName.nn
34+
override def toString() = this.getClass.getName
3535

3636
/** Access non-initialized field */
3737
case class AccessNonInit(field: Symbol)(val trace: Trace) extends Error:

compiler/src/dotty/tools/dotc/transform/init/Trace.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ object Trace:
5151
val line =
5252
if pos.source.exists then
5353
val loc = "[ " + pos.source.file.name + ":" + (pos.line + 1) + " ]"
54-
val code = SyntaxHighlighting.highlight(pos.lineContent.trim.nn)
54+
val code = SyntaxHighlighting.highlight(pos.lineContent.trim)
5555
i"$code\t$loc"
5656
else
5757
tree match
5858
case defDef: DefTree =>
5959
// The definition can be huge, avoid printing the whole definition.
6060
defDef.symbol.showFullName
6161
case _ =>
62-
tree.show.split(System.lineSeparator(), 2).nn.head.nn
62+
tree.show.split(System.lineSeparator(), 2).head
6363

6464
val positionMarkerLine =
6565
if pos.exists && pos.source.exists then
@@ -86,7 +86,7 @@ object Trace:
8686
*/
8787
private def positionMarker(pos: SourcePosition): String =
8888
val trimmed = pos.source.lineContent(pos.start).takeWhile(c => c.isWhitespace).length
89-
val padding = pos.startColumnPadding.substring(trimmed).nn
89+
val padding = pos.startColumnPadding.substring(trimmed)
9090
val carets =
9191
if (pos.startLine == pos.endLine)
9292
"^" * math.max(1, pos.endColumn - pos.startColumn)

compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
7474
def loop(remaining: List[String], n: Int): Unit =
7575
remaining match
7676
case part0 :: more =>
77-
def badPart(t: Throwable): String = "".tap(_ => report.partError(t.getMessage.nn, index = n, offset = 0))
77+
def badPart(t: Throwable): String = "".tap(_ => report.partError(t.getMessage, index = n, offset = 0))
7878
val part = try StringContext.processEscapes(part0) catch badPart
7979
val matches = formatPattern.findAllMatchIn(part)
8080

compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
651651
val dotIndex = pathName.indexOf('.')
652652
val globalRef =
653653
if (dotIndex < 0) pathName
654-
else pathName.substring(0, dotIndex).nn
654+
else pathName.substring(0, dotIndex)
655655
checkGlobalRefName(globalRef)
656656
}
657657

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,9 @@ object RefChecks {
12591259
val matches = referencePattern.findAllIn(s)
12601260
for reference <- matches do
12611261
val referenceOffset = matches.start
1262-
val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "").nn
1262+
val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "")
12631263
val variableOffset = referenceOffset + reference.length - prefixlessReference.length
1264-
val variableName = prefixlessReference.replaceFirst("""\s*\}""", "").nn
1264+
val variableName = prefixlessReference.replaceFirst("""\s*\}""", "")
12651265
f(variableName, variableOffset)
12661266

12671267
end checkImplicitNotFoundAnnotation

compiler/src/dotty/tools/dotc/util/ShowPickled.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ object ShowPickled {
113113
result.toInt
114114
}
115115

116-
def printFile(buf: PickleBuffer, out: PrintStream = System.out.nn): Unit = {
116+
def printFile(buf: PickleBuffer, out: PrintStream = System.out): Unit = {
117117
out.println("Version " + buf.readNat() + "." + buf.readNat())
118118
val index = buf.createIndex
119119
val entryList = makeEntryList(buf, index)

0 commit comments

Comments
 (0)