diff --git a/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala b/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala index e2730c1e84ab..e2ce73f79028 100644 --- a/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala +++ b/compiler/src/dotty/tools/backend/jvm/ClassfileWriters.scala @@ -18,8 +18,6 @@ import BTypes.InternalName import scala.util.chaining.* import dotty.tools.io.JarArchive -import scala.language.unsafeNulls - /** !!! This file is now copied in `dotty.tools.io.FileWriters` in a more general way that does not rely upon * `PostProcessorFrontendAccess`, this should probably be changed to wrap that class instead. * @@ -54,11 +52,11 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { def close(): Unit protected def classRelativePath(className: InternalName, suffix: String = ".class"): String = - className.replace('.', '/').nn + suffix + className.replace('.', '/') + suffix } object ClassfileWriter { - private def getDirectory(dir: String): Path = Paths.get(dir).nn + private def getDirectory(dir: String): Path = Paths.get(dir) def apply(): ClassfileWriter = { val jarManifestMainClass: Option[String] = compilerSettings.mainClass.orElse { @@ -137,7 +135,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { new JarEntryWriter(jarFile, jarManifestMainClass, jarCompressionLevel) } else if (file.isVirtual) new VirtualFileWriter(file) - else if (file.isDirectory) new DirEntryWriter(file.file.toPath.nn) + else if (file.isDirectory) new DirEntryWriter(file.file.toPath) else throw new IllegalStateException(s"don't know how to handle an output of $file [${file.getClass}]") } @@ -151,7 +149,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { val jarWriter: JarOutputStream = { import scala.util.Properties.* val manifest = new Manifest - val attrs = manifest.getMainAttributes.nn + val attrs = manifest.getMainAttributes attrs.put(MANIFEST_VERSION, "1.0") attrs.put(ScalaCompilerVersion, versionNumberString) mainClass.foreach(c => attrs.put(MAIN_CLASS, c)) @@ -184,7 +182,7 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { // important detail here, even on Windows, Zinc expects the separator within the jar // to be the system default, (even if in the actual jar file the entry always uses '/'). // see https://github.com/sbt/zinc/blob/dcddc1f9cfe542d738582c43f4840e17c053ce81/internal/compiler-bridge/src/main/scala/xsbt/JarUtils.scala#L47 - val pathInJar = + val pathInJar = if File.separatorChar == '/' then relativePath else relativePath.replace('/', File.separatorChar) PlainFile.toPlainFile(Paths.get(s"${file.absolutePath}!$pathInJar")) @@ -293,5 +291,5 @@ class ClassfileWriters(frontendAccess: PostProcessorFrontendAccess) { } /** Can't output a file due to the state of the file system. */ - class FileConflictException(msg: String, cause: Throwable = null) extends IOException(msg, cause) + class FileConflictException(msg: String, cause: Throwable | Null = null) extends IOException(msg, cause) } diff --git a/compiler/src/dotty/tools/dotc/Driver.scala b/compiler/src/dotty/tools/dotc/Driver.scala index 98abe2ac6c38..a401bb689db0 100644 --- a/compiler/src/dotty/tools/dotc/Driver.scala +++ b/compiler/src/dotty/tools/dotc/Driver.scala @@ -38,7 +38,7 @@ class Driver { finish(compiler, run) catch case ex: FatalError => - report.error(ex.getMessage.nn) // signals that we should fail compilation. + report.error(ex.getMessage) // signals that we should fail compilation. case ex: Throwable if ctx.usedBestEffortTasty => report.bestEffortError(ex, "Some best-effort tasty files were not able to be read.") throw ex @@ -117,7 +117,7 @@ class Driver { .distinct val ctx1 = ctx.fresh val fullClassPath = - (newEntries :+ ctx.settings.classpath.value).mkString(java.io.File.pathSeparator.nn) + (newEntries :+ ctx.settings.classpath.value).mkString(java.io.File.pathSeparator) ctx1.setSetting(ctx1.settings.classpath, fullClassPath) else ctx diff --git a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala index ec134149eb49..500765b04980 100644 --- a/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala +++ b/compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala @@ -963,7 +963,7 @@ class CheckCaptures extends Recheck, SymTransformer: trace.force(i"rechecking $tree with pt = $pt", recheckr, show = true): super.recheck(tree, pt) catch case ex: NoCommonRoot => - report.error(ex.getMessage.nn) + report.error(ex.getMessage) tree.tpe finally curEnv = saved if tree.isTerm then diff --git a/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala b/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala index 080f8d4e63d2..416bcc85a783 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala @@ -67,7 +67,7 @@ class ClassPathFactory { for file <- files a <- ClassPath.expandManifestPath(file.absolutePath) - path = java.nio.file.Paths.get(a.toURI()).nn + path = java.nio.file.Paths.get(a.toURI()) if Files.exists(path) yield newClassPath(AbstractFile.getFile(path)) diff --git a/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala b/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala index 855c0410042a..50aa89779f50 100644 --- a/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala +++ b/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala @@ -118,8 +118,8 @@ object CommandLineParser: Nil else def stripComment(s: String) = s.indexOf('#') match { case -1 => s case i => s.substring(0, i) } - val lines = Files.readAllLines(path).nn - val params = lines.asScala.map(stripComment).filter(!_.nn.isEmpty).mkString(" ") + val lines = Files.readAllLines(path) + val params = lines.asScala.map(stripComment).filter(!_.isEmpty).mkString(" ") tokenize(params) class ParseException(msg: String) extends RuntimeException(msg) diff --git a/compiler/src/dotty/tools/dotc/core/Comments.scala b/compiler/src/dotty/tools/dotc/core/Comments.scala index 92160c97973d..5ee1d5856605 100644 --- a/compiler/src/dotty/tools/dotc/core/Comments.scala +++ b/compiler/src/dotty/tools/dotc/core/Comments.scala @@ -2,8 +2,6 @@ package dotty.tools package dotc package core -import scala.language.unsafeNulls - import ast.{ untpd, tpd } import Symbols.*, Contexts.* import util.{SourceFile, ReadOnlyMap} diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala index 29d4b3fa4052..765fbd2907fc 100644 --- a/compiler/src/dotty/tools/dotc/core/Decorators.scala +++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala @@ -51,7 +51,7 @@ object Decorators { if name.length != 0 then name.getChars(0, name.length, chars, s.length) termName(chars, 0, len) case name: TypeName => s.concat(name.toTermName) - case _ => termName(s.concat(name.toString).nn) + case _ => termName(s.concat(name.toString)) def indented(width: Int): String = val padding = " " * width @@ -289,10 +289,10 @@ object Decorators { case NonFatal(ex) if !ctx.settings.YshowPrintErrors.value => s"... (cannot display due to ${ex.className} ${ex.getMessage}) ..." - case _ => String.valueOf(x).nn + case _ => String.valueOf(x) /** Returns the simple class name of `x`. */ - def className: String = x.getClass.getSimpleName.nn + def className: String = x.getClass.getSimpleName extension [T](x: T) def assertingErrorsReported(using Context): T = { diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 544718508e9e..ce726785e7e7 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -15,7 +15,7 @@ import nme.* object NameOps { object compactify { - lazy val md5: MessageDigest = MessageDigest.getInstance("MD5").nn + lazy val md5: MessageDigest = MessageDigest.getInstance("MD5") inline val CLASSFILE_NAME_CHAR_LIMIT = 240 @@ -43,7 +43,7 @@ object NameOps { val suffix = s.takeRight(edge) val cs = s.toArray - val bytes = Codec.toUTF8(CharBuffer.wrap(cs).nn) + val bytes = Codec.toUTF8(CharBuffer.wrap(cs)) md5.update(bytes) val md5chars = md5.digest().map(b => (b & 0xFF).toHexString).mkString diff --git a/compiler/src/dotty/tools/dotc/core/TypeErrors.scala b/compiler/src/dotty/tools/dotc/core/TypeErrors.scala index a65c0ada0c24..ce14cad6871c 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErrors.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErrors.scala @@ -32,7 +32,7 @@ abstract class TypeError(using creationContext: Context) extends Exception(""): || ctx.settings.YdebugCyclic.value override def fillInStackTrace(): Throwable = - if computeStackTrace then super.fillInStackTrace().nn + if computeStackTrace then super.fillInStackTrace() else this /** Convert to message. This takes an additional Context, so that we diff --git a/compiler/src/dotty/tools/dotc/core/TypeEval.scala b/compiler/src/dotty/tools/dotc/core/TypeEval.scala index 4d5496cff880..a6c308bb2a55 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeEval.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeEval.scala @@ -94,7 +94,7 @@ object TypeEval: val result = try op catch case e: Throwable => - throw TypeError(em"${e.getMessage.nn}") + throw TypeError(em"${e.getMessage}") ConstantType(Constant(result)) def fieldsOf: Option[Type] = diff --git a/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala index 43a2bea27216..c5770d69b002 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala @@ -1,7 +1,6 @@ package dotty.tools.dotc package core.tasty -import scala.language.unsafeNulls import scala.collection.immutable.BitSet import scala.collection.immutable.TreeMap diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala index 72f6895f122c..ee798e29721e 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala @@ -53,7 +53,7 @@ object TastyPrinter: else if arg.endsWith(".tasty") || (allowBetasty && arg.endsWith(".betasty")) then val path = Paths.get(arg) if Files.exists(path) then - printTasty(arg, Files.readAllBytes(path).nn, arg.endsWith(".betasty")) + printTasty(arg, Files.readAllBytes(path), arg.endsWith(".betasty")) else println("File not found: " + arg) System.exit(1) diff --git a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala index a6672d475129..490d1683b304 100644 --- a/compiler/src/dotty/tools/dotc/plugins/Plugins.scala +++ b/compiler/src/dotty/tools/dotc/plugins/Plugins.scala @@ -1,8 +1,6 @@ package dotty.tools.dotc package plugins -import scala.language.unsafeNulls - import core.* import Contexts.* import Decorators.em @@ -47,13 +45,12 @@ trait Plugins { goods map (_.get) } - private var _roughPluginsList: List[Plugin] = uninitialized + private var _roughPluginsList: List[Plugin] | Null = null protected def roughPluginsList(using Context): List[Plugin] = if (_roughPluginsList == null) { _roughPluginsList = loadRoughPluginsList - _roughPluginsList } - else _roughPluginsList + _roughPluginsList.nn /** Load all available plugins. Skips plugins that * either have the same name as another one, or which @@ -99,13 +96,12 @@ trait Plugins { plugs } - private var _plugins: List[Plugin] = uninitialized + private var _plugins: List[Plugin] | Null = null def plugins(using Context): List[Plugin] = if (_plugins == null) { _plugins = loadPlugins - _plugins } - else _plugins + _plugins.nn /** A description of all the plugins that are loaded */ def pluginDescriptions(using Context): String = diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index b5ed3bdb4fa7..00b22f2b7df3 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -394,7 +394,7 @@ class PlainPrinter(_ctx: Context) extends Printer { case tp: ThisType => nameString(tp.cls) + ".this" case SuperType(thistpe: SingletonType, _) => - toTextRef(thistpe).map(_.replaceAll("""\bthis$""", "super").nn) + toTextRef(thistpe).map(_.replaceAll("""\bthis$""", "super")) case SuperType(thistpe, _) => "Super(" ~ toTextGlobal(thistpe) ~ ")" case tp @ ConstantType(value) => @@ -628,7 +628,7 @@ class PlainPrinter(_ctx: Context) extends Printer { case '"' => "\\\"" case '\'' => "\\\'" case '\\' => "\\\\" - case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch).nn + case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch) } def toText(const: Constant): Text = const.tag match { @@ -638,7 +638,7 @@ class PlainPrinter(_ctx: Context) extends Printer { case LongTag => literalText(const.longValue.toString + "L") case DoubleTag => literalText(const.doubleValue.toString + "d") case FloatTag => literalText(const.floatValue.toString + "f") - case _ => literalText(String.valueOf(const.value).nn) + case _ => literalText(String.valueOf(const.value)) } /** Usual target for `Annotation#toText`, overridden in RefinedPrinter */ diff --git a/compiler/src/dotty/tools/dotc/printing/Showable.scala b/compiler/src/dotty/tools/dotc/printing/Showable.scala index 4480aa9c76a4..490778a7413a 100644 --- a/compiler/src/dotty/tools/dotc/printing/Showable.scala +++ b/compiler/src/dotty/tools/dotc/printing/Showable.scala @@ -25,7 +25,7 @@ trait Showable extends Any { /** The string representation with each line after the first one indented * by the given given margin (in spaces). */ - def showIndented(margin: Int)(using Context): String = show.replace("\n", "\n" + " " * margin).nn + def showIndented(margin: Int)(using Context): String = show.replace("\n", "\n" + " " * margin) /** The summarized string representation of this showable element. * Recursion depth is limited to some smallish value. Default is diff --git a/compiler/src/dotty/tools/dotc/printing/Texts.scala b/compiler/src/dotty/tools/dotc/printing/Texts.scala index 4db0c83fed58..014765b63274 100644 --- a/compiler/src/dotty/tools/dotc/printing/Texts.scala +++ b/compiler/src/dotty/tools/dotc/printing/Texts.scala @@ -5,7 +5,7 @@ import scala.annotation.internal.sharable object Texts { @sharable - private val ansi = java.util.regex.Pattern.compile("\u001b\\[\\d+m").nn + private val ansi = java.util.regex.Pattern.compile("\u001b\\[\\d+m") sealed abstract class Text { diff --git a/compiler/src/dotty/tools/dotc/quoted/Interpreter.scala b/compiler/src/dotty/tools/dotc/quoted/Interpreter.scala index e34d35065476..dbc2694dc891 100644 --- a/compiler/src/dotty/tools/dotc/quoted/Interpreter.scala +++ b/compiler/src/dotty/tools/dotc/quoted/Interpreter.scala @@ -1,8 +1,6 @@ package dotty.tools.dotc package quoted -import scala.language.unsafeNulls - import scala.collection.mutable import scala.reflect.ClassTag diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 01eb2acfa4de..396f2eadc332 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -92,7 +92,7 @@ abstract class CyclicMsg(errorId: ErrorMessageID)(using Context) extends Message protected def debugInfo = if ctx.settings.YdebugCyclic.value then - "\n\nStacktrace:" ++ ex.getStackTrace().nn.mkString("\n ", "\n ", "") + "\n\nStacktrace:" ++ ex.getStackTrace().mkString("\n ", "\n ", "") else "\n\n Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace." protected def context: String = ex.optTrace match diff --git a/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala b/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala index f49b00089712..a20a0d181a55 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala @@ -420,7 +420,7 @@ object Scala3: else Descriptor.None def unescapeUnicode = - unicodeEscape.replaceAllIn(symbol, m => String.valueOf(Integer.parseInt(m.group(1), 16).toChar).nn) + unicodeEscape.replaceAllIn(symbol, m => String.valueOf(Integer.parseInt(m.group(1), 16).toChar)) def isJavaIdent = symbol.nonEmpty && isJavaIdentifierStart(symbol.head) && symbol.tail.forall(isJavaIdentifierPart) diff --git a/compiler/src/dotty/tools/dotc/transform/Pickler.scala b/compiler/src/dotty/tools/dotc/transform/Pickler.scala index c8c071064ab8..108277599010 100644 --- a/compiler/src/dotty/tools/dotc/transform/Pickler.scala +++ b/compiler/src/dotty/tools/dotc/transform/Pickler.scala @@ -258,7 +258,7 @@ class Pickler extends Phase { } private def computeInternalName(cls: ClassSymbol)(using Context): String = - if cls.is(Module) then cls.binaryClassName.stripSuffix(str.MODULE_SUFFIX).nn + if cls.is(Module) then cls.binaryClassName.stripSuffix(str.MODULE_SUFFIX) else cls.binaryClassName override def run(using Context): Unit = { @@ -413,11 +413,11 @@ class Pickler extends Phase { ) if ctx.isBestEffort then val outpath = - ctx.settings.outputDir.value.jpath.toAbsolutePath.nn.normalize.nn - .resolve("META-INF").nn + ctx.settings.outputDir.value.jpath.toAbsolutePath.normalize + .resolve("META-INF") .resolve("best-effort") Files.createDirectories(outpath) - BestEffortTastyWriter.write(outpath.nn, result) + BestEffortTastyWriter.write(outpath, result) result } diff --git a/compiler/src/dotty/tools/dotc/transform/init/Errors.scala b/compiler/src/dotty/tools/dotc/transform/init/Errors.scala index 85feb609c90a..0b843b4b33fd 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Errors.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Errors.scala @@ -31,7 +31,7 @@ object Errors: report.warning(show, this.pos) end Error - override def toString() = this.getClass.getName.nn + override def toString() = this.getClass.getName /** Access non-initialized field */ case class AccessNonInit(field: Symbol)(val trace: Trace) extends Error: diff --git a/compiler/src/dotty/tools/dotc/transform/init/Trace.scala b/compiler/src/dotty/tools/dotc/transform/init/Trace.scala index ffaccad963af..9a00589197d5 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Trace.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Trace.scala @@ -51,7 +51,7 @@ object Trace: val line = if pos.source.exists then val loc = "[ " + pos.source.file.name + ":" + (pos.line + 1) + " ]" - val code = SyntaxHighlighting.highlight(pos.lineContent.trim.nn) + val code = SyntaxHighlighting.highlight(pos.lineContent.trim) i"$code\t$loc" else tree match @@ -59,7 +59,7 @@ object Trace: // The definition can be huge, avoid printing the whole definition. defDef.symbol.showFullName case _ => - tree.show.split(System.lineSeparator(), 2).nn.head.nn + tree.show.split(System.lineSeparator(), 2).head val positionMarkerLine = if pos.exists && pos.source.exists then @@ -86,7 +86,7 @@ object Trace: */ private def positionMarker(pos: SourcePosition): String = val trimmed = pos.source.lineContent(pos.start).takeWhile(c => c.isWhitespace).length - val padding = pos.startColumnPadding.substring(trimmed).nn + val padding = pos.startColumnPadding.substring(trimmed) val carets = if (pos.startLine == pos.endLine) "^" * math.max(1, pos.endColumn - pos.startColumn) diff --git a/compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala b/compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala index 9e40792895c0..5ac96f58011b 100644 --- a/compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala @@ -74,7 +74,7 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List def loop(remaining: List[String], n: Int): Unit = remaining match case part0 :: more => - def badPart(t: Throwable): String = "".tap(_ => report.partError(t.getMessage.nn, index = n, offset = 0)) + def badPart(t: Throwable): String = "".tap(_ => report.partError(t.getMessage, index = n, offset = 0)) val part = try StringContext.processEscapes(part0) catch badPart val matches = formatPattern.findAllMatchIn(part) diff --git a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala index 1b8fdd268ece..595a2e9a70ad 100644 --- a/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala +++ b/compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala @@ -651,7 +651,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP val dotIndex = pathName.indexOf('.') val globalRef = if (dotIndex < 0) pathName - else pathName.substring(0, dotIndex).nn + else pathName.substring(0, dotIndex) checkGlobalRefName(globalRef) } diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 0a0356707048..c9cd2b05a94a 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -1259,9 +1259,9 @@ object RefChecks { val matches = referencePattern.findAllIn(s) for reference <- matches do val referenceOffset = matches.start - val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "").nn + val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "") val variableOffset = referenceOffset + reference.length - prefixlessReference.length - val variableName = prefixlessReference.replaceFirst("""\s*\}""", "").nn + val variableName = prefixlessReference.replaceFirst("""\s*\}""", "") f(variableName, variableOffset) end checkImplicitNotFoundAnnotation diff --git a/compiler/src/dotty/tools/dotc/util/ShowPickled.scala b/compiler/src/dotty/tools/dotc/util/ShowPickled.scala index 8d5d0c27ab0e..15d553e703b3 100644 --- a/compiler/src/dotty/tools/dotc/util/ShowPickled.scala +++ b/compiler/src/dotty/tools/dotc/util/ShowPickled.scala @@ -113,7 +113,7 @@ object ShowPickled { result.toInt } - def printFile(buf: PickleBuffer, out: PrintStream = System.out.nn): Unit = { + def printFile(buf: PickleBuffer, out: PrintStream = System.out): Unit = { out.println("Version " + buf.readNat() + "." + buf.readNat()) val index = buf.createIndex val entryList = makeEntryList(buf, index) diff --git a/compiler/src/dotty/tools/io/FileWriters.scala b/compiler/src/dotty/tools/io/FileWriters.scala index 38bca796373e..849b80c5e745 100644 --- a/compiler/src/dotty/tools/io/FileWriters.scala +++ b/compiler/src/dotty/tools/io/FileWriters.scala @@ -189,7 +189,7 @@ object FileWriters { def close(): Unit protected def classToRelativePath(className: InternalName): String = - className.replace('.', '/').nn + ".tasty" + className.replace('.', '/') + ".tasty" } object TastyWriter { @@ -234,7 +234,7 @@ object FileWriters { new JarEntryWriter(jarFile, jarManifestMainClass, jarCompressionLevel) } else if (file.isVirtual) new VirtualFileWriter(file) - else if (file.isDirectory) new DirEntryWriter(file.file.toPath.nn) + else if (file.isDirectory) new DirEntryWriter(file.file.toPath) else throw new IllegalStateException(s"don't know how to handle an output of $file [${file.getClass}]") } @@ -248,7 +248,7 @@ object FileWriters { val jarWriter: JarOutputStream = { import scala.util.Properties.* val manifest = new Manifest - val attrs = manifest.getMainAttributes.nn + val attrs = manifest.getMainAttributes attrs.put(MANIFEST_VERSION, "1.0") attrs.put(ScalaCompilerVersion, versionNumberString) mainClass.foreach(c => attrs.put(MAIN_CLASS, c)) diff --git a/compiler/src/dotty/tools/io/Path.scala b/compiler/src/dotty/tools/io/Path.scala index 6f97e03ca4d7..39665395c289 100644 --- a/compiler/src/dotty/tools/io/Path.scala +++ b/compiler/src/dotty/tools/io/Path.scala @@ -5,8 +5,6 @@ package dotty.tools.io -import scala.language.unsafeNulls - import java.io.RandomAccessFile import java.nio.file.* import java.net.{URI, URL} @@ -46,7 +44,7 @@ object Path { def fileName(name: String): String = { val i = name.lastIndexOf('.') if (i < 0) name - else name.substring(0, i).nn + else name.substring(0, i) } def onlyDirs(xs: Iterator[Path]): Iterator[Directory] = xs.filter(_.isDirectory).map(_.toDirectory) diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index 9503177ff738..86ba6708caba 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -1441,7 +1441,7 @@ object SourceCode { case '"' => "\\\"" case '\'' => "\\\'" case '\\' => "\\\\" - case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch).nn + case _ => if ch.isControl then f"${"\\"}u${ch.toInt}%04x" else String.valueOf(ch) } private def escapedString(str: String): String = str flatMap escapedChar diff --git a/compiler/test/dotty/tools/backend/jvm/StringConcatTest.scala b/compiler/test/dotty/tools/backend/jvm/StringConcatTest.scala index 14352106c5e8..613e72b32e52 100644 --- a/compiler/test/dotty/tools/backend/jvm/StringConcatTest.scala +++ b/compiler/test/dotty/tools/backend/jvm/StringConcatTest.scala @@ -122,7 +122,7 @@ class StringConcatTest extends DottyBytecodeTest { chsq: java.lang.CharSequence, chrs: Array[Char]) = { val s1 = str + obj + v + z + c + b + s + i + f + l + d + sbuf + chsq + chrs - val s2 = String.valueOf(obj).nn + str + v + z + c + b + s + i + f + l + d + sbuf + chsq + chrs + val s2 = String.valueOf(obj) + str + v + z + c + b + s + i + f + l + d + sbuf + chsq + chrs s1 + "//" + s2 } def sbuf = { val r = new java.lang.StringBuffer(); r.append("sbuf"); r } diff --git a/compiler/test/dotty/tools/dotc/SettingsTests.scala b/compiler/test/dotty/tools/dotc/SettingsTests.scala index 996ab22f67b1..ec342db875a6 100644 --- a/compiler/test/dotty/tools/dotc/SettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/SettingsTests.scala @@ -1,8 +1,6 @@ package dotty.tools package dotc -import scala.language.unsafeNulls - import reporting.StoreReporter import vulpix.TestConfiguration @@ -205,7 +203,7 @@ class SettingsTests { } @Test def `Output setting is overriding existing jar`: Unit = - val result = Using.resource(Files.createTempFile("myfile", ".jar").nn){ file => + val result = Using.resource(Files.createTempFile("myfile", ".jar")){ file => object Settings extends SettingGroup: val defaultDir = new PlainDirectory(Directory(".")) val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir) @@ -224,7 +222,7 @@ class SettingsTests { @Test def `Output setting is respecting previous setting`: Unit = val result = Using.resources( - Files.createTempFile("myfile", ".jar").nn, Files.createTempFile("myfile2", ".jar").nn + Files.createTempFile("myfile", ".jar"), Files.createTempFile("myfile2", ".jar") ){ (file1, file2) => object Settings extends SettingGroup: val defaultDir = new PlainDirectory(Directory(".")) @@ -250,7 +248,7 @@ class SettingsTests { }(Files.deleteIfExists(_), Files.deleteIfExists(_)) @Test def `Output side effect is not present when setting is deprecated`: Unit = - val result = Using.resource(Files.createTempFile("myfile", ".jar").nn){ file => + val result = Using.resource(Files.createTempFile("myfile", ".jar")){ file => object Settings extends SettingGroup: val defaultDir = new PlainDirectory(Directory(".")) val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir, preferPrevious = true, deprecation = Deprecation.renamed("XtestOutput")) diff --git a/compiler/test/dotty/tools/dotc/TupleShowTests.scala b/compiler/test/dotty/tools/dotc/TupleShowTests.scala index 2d76c480b001..88e0587d7d71 100644 --- a/compiler/test/dotty/tools/dotc/TupleShowTests.scala +++ b/compiler/test/dotty/tools/dotc/TupleShowTests.scala @@ -71,7 +71,7 @@ class TupleShowTests extends DottyTest: /** On Windows the string literal in this test source file will be read with `\n` (b/c of "-encoding UTF8") * but the compiler will correctly emit \r\n as the line separator. * So we align the expected result to faithfully compare test results. */ - extension (str: String) def normEOL = if EOL == "\n" then str else str.replace("\n", EOL).nn + extension (str: String) def normEOL = if EOL == "\n" then str else str.replace("\n", EOL) def diff(exp: String, obt: String) = val min = math.min(exp.length, obt.length) diff --git a/compiler/test/dotty/tools/dotc/core/tasty/TastyHeaderUnpicklerTest.scala b/compiler/test/dotty/tools/dotc/core/tasty/TastyHeaderUnpicklerTest.scala index bde4246ef0f0..ddc88803854f 100644 --- a/compiler/test/dotty/tools/dotc/core/tasty/TastyHeaderUnpicklerTest.scala +++ b/compiler/test/dotty/tools/dotc/core/tasty/TastyHeaderUnpicklerTest.scala @@ -265,7 +265,7 @@ class TastyHeaderUnpicklerTest { object TastyHeaderUnpicklerTest { def fillHeader(maj: Int, min: Int, exp: Int, compiler: String): TastyBuffer = { - val compilerBytes = compiler.getBytes(java.nio.charset.StandardCharsets.UTF_8).nn + val compilerBytes = compiler.getBytes(java.nio.charset.StandardCharsets.UTF_8) val buf = new TastyBuffer(header.length + 32 + compilerBytes.length) for (ch <- header) buf.writeByte(ch.toByte) buf.writeNat(maj) @@ -304,7 +304,7 @@ object TastyHeaderUnpicklerTest { fail() } catch { - case err: UnpickleException => assert(err.getMessage.nn.contains(message)) + case err: UnpickleException => assert(err.getMessage.contains(message)) } }