diff --git a/compiler/src/dotty/tools/MainGenericCompiler.scala b/compiler/src/dotty/tools/MainGenericCompiler.scala index aa924a237f73..2c3f6f97e79e 100644 --- a/compiler/src/dotty/tools/MainGenericCompiler.scala +++ b/compiler/src/dotty/tools/MainGenericCompiler.scala @@ -1,7 +1,5 @@ package dotty.tools -import scala.language.unsafeNulls - import scala.annotation.tailrec import scala.io.Source import scala.util.Try diff --git a/compiler/src/dotty/tools/backend/jvm/AsmUtils.scala b/compiler/src/dotty/tools/backend/jvm/AsmUtils.scala index e6393ce82054..8a71a09aa7ab 100644 --- a/compiler/src/dotty/tools/backend/jvm/AsmUtils.scala +++ b/compiler/src/dotty/tools/backend/jvm/AsmUtils.scala @@ -2,8 +2,6 @@ package dotty.tools package backend package jvm -import scala.language.unsafeNulls - import scala.tools.asm.tree.{AbstractInsnNode} import java.io.PrintWriter import scala.tools.asm.util.{TraceClassVisitor, TraceMethodVisitor, Textifier} 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/backend/jvm/PostProcessor.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala index 06c3c7f1cb4f..599b09273046 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala @@ -36,7 +36,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes: setInnerClasses(classNode) serializeClass(classNode) catch - case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.nn.contains("too large!") => + case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.contains("too large!") => backendReporting.error(em"Could not write class $internalName because it exceeds JVM code size limits. ${e.getMessage}") null case ex: Throwable => @@ -58,8 +58,8 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes: } private def warnCaseInsensitiveOverwrite(clazz: GeneratedClass) = { - val name = clazz.classNode.name.nn - val lowerCaseJavaName = name.nn.toLowerCase + val name = clazz.classNode.name + val lowerCaseJavaName = name.toLowerCase val clsPos = clazz.position caseInsensitively.putIfAbsent(lowerCaseJavaName, (name, clsPos)) match { case null => () diff --git a/compiler/src/dotty/tools/dotc/Bench.scala b/compiler/src/dotty/tools/dotc/Bench.scala index cbc490919cfe..26259dcaa28b 100644 --- a/compiler/src/dotty/tools/dotc/Bench.scala +++ b/compiler/src/dotty/tools/dotc/Bench.scala @@ -30,7 +30,7 @@ object Bench extends Driver: println(s"time elapsed: ${times(curRun)}ms") if ctx.settings.Xprompt.value || waitAfter == curRun + 1 then print("hit to continue >") - System.in.nn.read() + System.in.read() reporter def extractNumArg(args: Array[String], name: String, default: Int = 1): (Int, Array[String]) = { 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/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 11a0430480d9..ca51788c3a53 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -211,7 +211,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint try trackProgress(_.cancel()) finally - Thread.currentThread().nn.interrupt() + Thread.currentThread().interrupt() private def doAdvancePhase(currentPhase: Phase, wasRan: Boolean)(using Context): Unit = trackProgress: progress => diff --git a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala index 44d5e2cf4b88..e891e1b6d402 100644 --- a/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala +++ b/compiler/src/dotty/tools/dotc/cc/CaptureSet.scala @@ -630,7 +630,7 @@ object CaptureSet: // For debugging: A trace where a set was created. Note that logically it would make more // sense to place this variable in Mapped, but that runs afoul of the initializatuon checker. - val stack = if debugSets && this.isInstanceOf[Mapped] then (new Throwable).getStackTrace().nn.take(20) else null + val stack = if debugSets && this.isInstanceOf[Mapped] then (new Throwable).getStackTrace().take(20) else null /** The variable from which this variable is derived */ def source: Var 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 2e76561c9913..50aa89779f50 100644 --- a/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala +++ b/compiler/src/dotty/tools/dotc/config/CommandLineParser.scala @@ -114,12 +114,12 @@ object CommandLineParser: def expandArg(arg: String): List[String] = val path = Paths.get(arg.stripPrefix("@")) if !Files.exists(path) then - System.err.nn.println(s"Argument file ${path.nn.getFileName} could not be found") + System.err.println(s"Argument file ${path.getFileName} could not be found") 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/config/Printers.scala b/compiler/src/dotty/tools/dotc/config/Printers.scala index 81fd60497025..4c66e1cdf833 100644 --- a/compiler/src/dotty/tools/dotc/config/Printers.scala +++ b/compiler/src/dotty/tools/dotc/config/Printers.scala @@ -5,7 +5,7 @@ import core.Contexts.{Context, ctx} object Printers { class Printer { - def println(msg: => String): Unit = System.out.nn.println(msg) + def println(msg: => String): Unit = System.out.println(msg) } object noPrinter extends Printer { diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 72a051ea8154..9472b193ba02 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -1,7 +1,6 @@ package dotty.tools.dotc package config -import scala.language.unsafeNulls import dotty.tools.dotc.config.PathResolver.Defaults import dotty.tools.dotc.config.Settings.{Setting, SettingGroup, SettingCategory, Deprecation} import dotty.tools.dotc.config.SourceVersion diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala index 022916cc9f53..ecb10d30fce8 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala @@ -4,7 +4,6 @@ package config import Settings.Setting.ChoiceWithHelp import dotty.tools.backend.jvm.BackendUtils.classfileVersionMap import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile} -import scala.language.unsafeNulls object ScalaSettingsProperties: diff --git a/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala b/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala index 9f603e6792be..a9fffa7a3bb6 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala @@ -3,8 +3,6 @@ package dotty.tools package dotc.config -import scala.language.unsafeNulls - import scala.annotation.internal.sharable import scala.util.{Try, Success, Failure} @@ -82,20 +80,20 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu "The minor and revision parts are optional." )) - def toInt(s: String) = s match { + def toInt(s: String | Null) = s match { case null | "" => 0 - case _ => s.toInt + case _ => s.nn.toInt } def isInt(s: String) = Try(toInt(s)).isSuccess import ScalaBuild.* - def toBuild(s: String) = s match { + def toBuild(s: String | Null) = s match { case null | "FINAL" => Final case s if (s.toUpperCase.startsWith("RC") && isInt(s.substring(2))) => RC(toInt(s.substring(2))) case s if (s.toUpperCase.startsWith("M") && isInt(s.substring(1))) => Milestone(toInt(s.substring(1))) - case _ => Development(s) + case _ => Development(s.nn) } try versionString match { diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index a5fc6a64aa45..8444d6261721 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -1,8 +1,6 @@ package dotty.tools.dotc package config -import scala.language.unsafeNulls - import core.Contexts.* import dotty.tools.io.{AbstractFile, Directory, JarArchive, PlainDirectory} 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/MacroClassLoader.scala b/compiler/src/dotty/tools/dotc/core/MacroClassLoader.scala index b6b316ac14d9..c4c41a460a70 100644 --- a/compiler/src/dotty/tools/dotc/core/MacroClassLoader.scala +++ b/compiler/src/dotty/tools/dotc/core/MacroClassLoader.scala @@ -19,8 +19,6 @@ object MacroClassLoader { ctx.setProperty(MacroClassLoaderKey, makeMacroClassLoader(using ctx)) private def makeMacroClassLoader(using Context): ClassLoader = trace("new macro class loader") { - import scala.language.unsafeNulls - val entries = ClassPath.expandPath(ctx.settings.classpath.value, expandStar=true) val urls = entries.map(cp => java.nio.file.Paths.get(cp).toUri.toURL).toArray val out = Option(ctx.settings.outputDir.value.toURL) // to find classes in case of suspended compilation diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index 415aa049c587..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,9 +43,9 @@ 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().nn.map(b => (b & 0xFF).toHexString).mkString + val md5chars = md5.digest().map(b => (b & 0xFF).toHexString).mkString prefix + marker + md5chars + marker + suffix } diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala index 3f9667b08067..baf95b9306d3 100644 --- a/compiler/src/dotty/tools/dotc/core/Names.scala +++ b/compiler/src/dotty/tools/dotc/core/Names.scala @@ -393,7 +393,7 @@ object Names { // because asserts are caught in exception handlers which might // cause other failures. In that case the first, important failure // is lost. - System.err.nn.println("Backend should not call Name#toString, Name#mangledString should be used instead.") + System.err.println("Backend should not call Name#toString, Name#mangledString should be used instead.") Thread.dumpStack() assert(false) } @@ -404,8 +404,8 @@ object Names { * from GenBCode or it also contains one of the whitelisted methods below. */ private def toStringOK = { - val trace: Array[StackTraceElement] = Thread.currentThread.nn.getStackTrace.asInstanceOf[Array[StackTraceElement]] - !trace.exists(_.getClassName.nn.endsWith("GenBCode")) || + val trace: Array[StackTraceElement] = Thread.currentThread.getStackTrace.asInstanceOf[Array[StackTraceElement]] + !trace.exists(_.getClassName.endsWith("GenBCode")) || trace.exists(elem => List( "mangledString", diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index d3e198a7e7a7..a981f942016c 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -42,7 +42,7 @@ object StdNames { @sharable private val disallowed = java.util.regex.Pattern.compile("""[<>]""").nn - def sanitize(str: String): String = disallowed.matcher(str).nn.replaceAll("""\$""").nn + def sanitize(str: String): String = disallowed.matcher(str).replaceAll("""\$""").nn } abstract class DefinedNames[N <: Name] { diff --git a/compiler/src/dotty/tools/dotc/core/TypeErrors.scala b/compiler/src/dotty/tools/dotc/core/TypeErrors.scala index 1c9696da67d1..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 @@ -246,7 +246,7 @@ class UnpicklingError(denot: Denotation, where: String, cause: Throwable)(using case cause: UnpicklingError => "" case _ => if ctx.settings.YdebugUnpickling.value then - cause.getStackTrace().nn.mkString("\n ", "\n ", "") + cause.getStackTrace().mkString("\n ", "\n ", "") else "\n\nRun with -Ydebug-unpickling to see full stack trace." em"""Could not read definition $denot$where. Caused by the following exception: |$cause$debugUnpickling""" 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/classfile/AbstractFileReader.scala b/compiler/src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala index 46581d00714e..d4f781e22126 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala @@ -3,8 +3,6 @@ package dotc package core package classfile -import scala.language.unsafeNulls - import java.lang.Float.intBitsToFloat import java.lang.Double.longBitsToDouble import java.io.{ByteArrayInputStream, DataInputStream} 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/parsing/JavaScanners.scala b/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala index 3f993195e4f3..64f586ca0410 100644 --- a/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala @@ -666,7 +666,7 @@ object JavaScanners { val limit: Double = if (token == DOUBLELIT) Double.MaxValue else Float.MaxValue try { - val value: Double = java.lang.Double.valueOf(strVal.toString).nn.doubleValue() + val value: Double = java.lang.Double.valueOf(strVal.toString).doubleValue() if (value > limit) error(em"floating point number too large") if (negated) -value else value 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 475e2c6900d5..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 { @@ -74,7 +74,7 @@ object Texts { else appendIndented(that)(width) private def lengthWithoutAnsi(str: String): Int = - ansi.matcher(str).nn.replaceAll("").nn.length + ansi.matcher(str).replaceAll("").length def layout(width: Int): Text = this match { case Str(s, _) => 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/report.scala b/compiler/src/dotty/tools/dotc/report.scala index e24e6be38b2b..9e79a3d5eef6 100644 --- a/compiler/src/dotty/tools/dotc/report.scala +++ b/compiler/src/dotty/tools/dotc/report.scala @@ -84,8 +84,8 @@ object report: def bestEffortError(ex: Throwable, msg: String)(using Context): Unit = val stackTrace = Option(ex.getStackTrace()).map { st => - if st.nn.isEmpty then "" - else s"Stack trace: \n ${st.nn.mkString("\n ")}".stripMargin + if st.isEmpty then "" + else s"Stack trace: \n ${st.mkString("\n ")}".stripMargin }.getOrElse("") // Build tools and dotty's test framework may check precisely for // "Unsuccessful best-effort compilation." error text. 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/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index b5b75450272c..0725d2f971e2 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -170,7 +170,7 @@ object GenericSignatures { def fullNameInSig(sym: Symbol): Unit = { assert(sym.isClass) val name = atPhase(genBCodePhase) { sanitizeName(sym.fullName).replace('.', '/') } - builder.append('L').nn.append(name) + builder.append('L').append(name) } def classSig(sym: Symbol, pre: Type = NoType, args: List[Type] = Nil): Unit = { @@ -215,7 +215,7 @@ object GenericSignatures { // TODO revisit this. Does it align with javac for code that can be expressed in both languages? val delimiter = if (builder.charAt(builder.length() - 1) == '>') '.' else '$' - builder.append(delimiter).nn.append(sanitizeName(sym.name)) + builder.append(delimiter).append(sanitizeName(sym.name)) } else fullNameInSig(sym) } diff --git a/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala b/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala index f5e0f8c63b58..a89e03f4fa6e 100644 --- a/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala +++ b/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala @@ -56,9 +56,9 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer: if !newlyCreated then // If the directory existed before, let's clean it up. - dataDir.listFiles.nn - .filter(_.nn.getName.nn.startsWith("scoverage")) - .foreach(_.nn.delete()) + dataDir.listFiles + .filter(_.getName.startsWith("scoverage")) + .foreach(_.delete()) end if coverageExcludeClasslikePatterns = ctx.settings.coverageExcludeClasslikes.value.map(_.r.pattern) @@ -71,13 +71,13 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer: private def isClassIncluded(sym: Symbol)(using Context): Boolean = val fqn = sym.fullName.toText(ctx.printerFn(ctx)).show coverageExcludeClasslikePatterns.isEmpty || !coverageExcludeClasslikePatterns.exists( - _.matcher(fqn).nn.matches + _.matcher(fqn).matches ) private def isFileIncluded(file: SourceFile)(using Context): Boolean = val normalizedPath = file.path.replace(".scala", "") coverageExcludeFilePatterns.isEmpty || !coverageExcludeFilePatterns.exists( - _.matcher(normalizedPath).nn.matches + _.matcher(normalizedPath).matches ) override protected def newTransformer(using Context) = 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/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index a2b403fdae6c..7eea19ba8807 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -860,7 +860,7 @@ object TreeChecker { val stack = if !ctx.settings.Ydebug.value then "\nstacktrace available when compiling with `-Ydebug`" else if err.getStackTrace == null then " no stacktrace" - else err.getStackTrace.nn.mkString(" ", " \n", "") + else err.getStackTrace.mkString(" ", " \n", "") report.error( em"""Malformed tree was found while expanding macro with -Xcheck-macros. 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/ParsedComment.scala b/compiler/src/dotty/tools/dotc/util/ParsedComment.scala index ee56a74d5eb5..acced8dd857c 100644 --- a/compiler/src/dotty/tools/dotc/util/ParsedComment.scala +++ b/compiler/src/dotty/tools/dotc/util/ParsedComment.scala @@ -1,7 +1,5 @@ package dotty.tools.dotc.util -import scala.language.unsafeNulls - import dotty.tools.dotc.core.Comments.{Comment, docCtx} import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.core.Names.TermName 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/File.scala b/compiler/src/dotty/tools/io/File.scala index 59e4a2ee451b..ea48966de6fb 100644 --- a/compiler/src/dotty/tools/io/File.scala +++ b/compiler/src/dotty/tools/io/File.scala @@ -8,8 +8,6 @@ package dotty.tools.io -import scala.language.unsafeNulls - import java.io.{File => JavaIoFile, _} import java.nio.file.{Files, Paths} import java.nio.file.StandardOpenOption.* diff --git a/compiler/src/dotty/tools/io/FileWriters.scala b/compiler/src/dotty/tools/io/FileWriters.scala index 5fdf43cfe8e3..849b80c5e745 100644 --- a/compiler/src/dotty/tools/io/FileWriters.scala +++ b/compiler/src/dotty/tools/io/FileWriters.scala @@ -66,7 +66,7 @@ object FileWriters { def warning(message: Context ?=> Message): Unit = warning(message, NoSourcePosition) final def exception(reason: Context ?=> Message, throwable: Throwable): Unit = error({ - val trace = throwable.getStackTrace().nn.mkString("\n ") + val trace = throwable.getStackTrace().mkString("\n ") em"An unhandled exception was thrown in the compiler while\n ${reason.message}.\n${throwable}\n $trace" }, NoSourcePosition) } @@ -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-coursier/dotty/tools/coursier/CoursierScalaTests.scala b/compiler/test-coursier/dotty/tools/coursier/CoursierScalaTests.scala index 86b22009d15a..f44774141947 100644 --- a/compiler/test-coursier/dotty/tools/coursier/CoursierScalaTests.scala +++ b/compiler/test-coursier/dotty/tools/coursier/CoursierScalaTests.scala @@ -159,7 +159,7 @@ object CoursierScalaTests: def csScalaCmd(options: String*): List[String] = csScalaCmdWithStdin(options, None) - + def csScalaCmdWithStdin(options: Seq[String], stdin: Option[String]): List[String] = csCmd("dotty.tools.MainGenericRunner", options, stdin) 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)) } } diff --git a/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala b/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala index 4ed59db5c10e..70f26dfd104e 100644 --- a/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala +++ b/compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala @@ -35,7 +35,7 @@ class PatmatExhaustivityTest { e.printStackTrace(printWriter) } - stringBuffer.toString.trim.nn.replaceAll("\\s+\n", "\n") match { + stringBuffer.toString.trim.replaceAll("\\s+\n", "\n") match { case "" => Nil case s => s.linesIterator.toSeq } diff --git a/library/src/scala/runtime/LazyVals.scala b/library/src/scala/runtime/LazyVals.scala index 15220ea2410a..5d4c508d2076 100644 --- a/library/src/scala/runtime/LazyVals.scala +++ b/library/src/scala/runtime/LazyVals.scala @@ -26,7 +26,7 @@ object LazyVals { } private val base: Int = { - val processors = java.lang.Runtime.getRuntime.nn.availableProcessors() + val processors = java.lang.Runtime.getRuntime.availableProcessors() 8 * processors * processors } diff --git a/library/src/scala/runtime/coverage/Invoker.scala b/library/src/scala/runtime/coverage/Invoker.scala index c35c6c2ec7df..b2159e6873f6 100644 --- a/library/src/scala/runtime/coverage/Invoker.scala +++ b/library/src/scala/runtime/coverage/Invoker.scala @@ -51,6 +51,6 @@ object Invoker { @nowarn("cat=deprecation") def measurementFile(dataDir: String): File = new File( dataDir, - MeasurementsPrefix + runtimeUUID + "." + Thread.currentThread.nn.getId + MeasurementsPrefix + runtimeUUID + "." + Thread.currentThread.getId ) } diff --git a/library/src/scala/util/FromDigits.scala b/library/src/scala/util/FromDigits.scala index cb73782829ff..44532649868d 100644 --- a/library/src/scala/util/FromDigits.scala +++ b/library/src/scala/util/FromDigits.scala @@ -135,7 +135,7 @@ object FromDigits { case ex: NumberFormatException => throw MalformedNumber() } if (x.isInfinite) throw NumberTooLarge() - if (x == 0.0f && !zeroFloat.pattern.matcher(digits).nn.matches) throw NumberTooSmall() + if (x == 0.0f && !zeroFloat.pattern.matcher(digits).matches) throw NumberTooSmall() x } diff --git a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala index 035c1062a3e3..21966499476f 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala @@ -105,6 +105,6 @@ class CompilerSearchVisitor( override def isCancelled: Boolean = false private def normalizePackage(pkg: String): String = - pkg.replace("/", ".").nn.stripSuffix(".") + pkg.replace("/", ".").stripSuffix(".") end CompilerSearchVisitor diff --git a/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala index ccda618078b8..0c08ed63ffe8 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala @@ -105,7 +105,7 @@ object SymbolProvider: catch case NonFatal(e) => Nil private def normalizePackage(pkg: String): String = - pkg.replace("/", ".").nn.stripSuffix(".") + pkg.replace("/", ".").stripSuffix(".") private def toSymbols(info: SymbolInfo.SymbolParts)(using Context): List[Symbol] = def collectSymbols(denotation: Denotation): List[Symbol] = diff --git a/presentation-compiler/src/main/dotty/tools/pc/TastyUtils.scala b/presentation-compiler/src/main/dotty/tools/pc/TastyUtils.scala index 62a947aeb50b..0c2afad5f92a 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/TastyUtils.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/TastyUtils.scala @@ -40,7 +40,7 @@ object TastyUtils: end htmlTasty private def tastyHtmlPageTitle(file: URI) = - val filename = Paths.get(file).nn.getFileName().toString + val filename = Paths.get(file).getFileName().toString s"TASTy for $filename" private val standaloneHtmlStyles = diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala index 81337c7d8dcb..a903aa5dea19 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala @@ -39,10 +39,10 @@ object AmmoniteFileCompletions: rawFileName: String )(using Context): List[CompletionValue] = val fileName: Option[String] = Option(rawFileName) - .flatMap(_.split("/").nn.lastOption.map(_.nn.stripSuffix(".amm.sc.scala"))) + .flatMap(_.split("/").lastOption.map(_.stripSuffix(".amm.sc.scala"))) val split: List[String] = Option(rawPath) - .fold(Nil)(_.split("\\$file").nn.toList.map(_.nn)) + .fold(Nil)(_.split("\\$file").toList.map(_.nn)) val editRange = selector.headOption.map { sel => if sel.sourcePos.span.isZeroExtent then posRange @@ -71,10 +71,10 @@ object AmmoniteFileCompletions: // drop / or \ val current = workspace.resolve(script.drop(1)) val importPath = translateImportToPath(select).drop(1) - val currentPath = current.nn.getParent().nn.resolve(importPath).nn.toAbsolutePath() + val currentPath = current.getParent().resolve(importPath).toAbsolutePath() val parentTextEdit = - if query.exists(_.nn.isEmpty()) && - Files.exists(currentPath.nn.getParent()) && Files.isDirectory( + if query.exists(_.isEmpty()) && + Files.exists(currentPath.getParent()) && Files.isDirectory( currentPath ) then List(parent) @@ -84,7 +84,7 @@ object AmmoniteFileCompletions: .iterator().nn .asScala .toList - .filter(path => !fileName.contains(path.nn.getFileName().toString.stripSuffix(".sc"))) + .filter(path => !fileName.contains(path.getFileName().toString.stripSuffix(".sc"))) .collect { case file if matches(file) => CompletionValue.FileSystemMember( diff --git a/project/Build.scala b/project/Build.scala index db1cf16588aa..9170760514f4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -986,7 +986,7 @@ object Build { // compiler is updated. // Then, the next step is to enable flexible types by default and reduce the use of // `unsafeNulls`. - scalacOptions ++= Seq("-Yno-flexible-types"), + // scalacOptions ++= Seq("-Yno-flexible-types"), packageAll := { (`scala3-compiler` / packageAll).value ++ Seq( "scala3-compiler" -> (Compile / packageBin).value.getAbsolutePath, @@ -1377,10 +1377,10 @@ object Build { .asScala3PresentationCompiler(NonBootstrapped) lazy val `scala3-presentation-compiler-bootstrapped` = project.in(file("presentation-compiler")) .asScala3PresentationCompiler(Bootstrapped) - .settings( - // Add `-Yno-flexible-types` flag for bootstrap, see comments for `bootstrappedDottyCompilerSettings` - Compile / scalacOptions += "-Yno-flexible-types" - ) + // .settings( + // // Add `-Yno-flexible-types` flag for bootstrap, see comments for `bootstrappedDottyCompilerSettings` + // Compile / scalacOptions += "-Yno-flexible-types" + // ) def scala3PresentationCompiler(implicit mode: Mode): Project = mode match { case NonBootstrapped => `scala3-presentation-compiler`