Skip to content

Commit c1ed612

Browse files
committed
Removed some nn and unsafeNulls
1 parent 65a53b5 commit c1ed612

23 files changed

+26
-40
lines changed

compiler/src/dotty/tools/MainGenericCompiler.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dotty.tools
22

3-
import scala.language.unsafeNulls
4-
53
import scala.annotation.tailrec
64
import scala.io.Source
75
import scala.util.Try

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package dotty.tools
22
package backend
33
package jvm
44

5-
import scala.language.unsafeNulls
6-
75
import scala.tools.asm.tree.{AbstractInsnNode}
86
import java.io.PrintWriter
97
import scala.tools.asm.util.{TraceClassVisitor, TraceMethodVisitor, Textifier}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes:
3636
setInnerClasses(classNode)
3737
serializeClass(classNode)
3838
catch
39-
case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.nn.contains("too large!") =>
39+
case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.contains("too large!") =>
4040
backendReporting.error(em"Could not write class $internalName because it exceeds JVM code size limits. ${e.getMessage}")
4141
null
4242
case ex: Throwable =>
@@ -58,8 +58,8 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes:
5858
}
5959

6060
private def warnCaseInsensitiveOverwrite(clazz: GeneratedClass) = {
61-
val name = clazz.classNode.name.nn
62-
val lowerCaseJavaName = name.nn.toLowerCase
61+
val name = clazz.classNode.name
62+
val lowerCaseJavaName = name.toLowerCase
6363
val clsPos = clazz.position
6464
caseInsensitively.putIfAbsent(lowerCaseJavaName, (name, clsPos)) match {
6565
case null => ()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Bench extends Driver:
3030
println(s"time elapsed: ${times(curRun)}ms")
3131
if ctx.settings.Xprompt.value || waitAfter == curRun + 1 then
3232
print("hit <return> to continue >")
33-
System.in.nn.read()
33+
System.in.read()
3434
reporter
3535

3636
def extractNumArg(args: Array[String], name: String, default: Int = 1): (Int, Array[String]) = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
211211
try
212212
trackProgress(_.cancel())
213213
finally
214-
Thread.currentThread().nn.interrupt()
214+
Thread.currentThread().interrupt()
215215

216216
private def doAdvancePhase(currentPhase: Phase, wasRan: Boolean)(using Context): Unit =
217217
trackProgress: progress =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ object CaptureSet:
630630

631631
// For debugging: A trace where a set was created. Note that logically it would make more
632632
// sense to place this variable in Mapped, but that runs afoul of the initializatuon checker.
633-
val stack = if debugSets && this.isInstanceOf[Mapped] then (new Throwable).getStackTrace().nn.take(20) else null
633+
val stack = if debugSets && this.isInstanceOf[Mapped] then (new Throwable).getStackTrace().take(20) else null
634634

635635
/** The variable from which this variable is derived */
636636
def source: Var

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ object CommandLineParser:
114114
def expandArg(arg: String): List[String] =
115115
val path = Paths.get(arg.stripPrefix("@"))
116116
if !Files.exists(path) then
117-
System.err.nn.println(s"Argument file ${path.nn.getFileName} could not be found")
117+
System.err.println(s"Argument file ${path.getFileName} could not be found")
118118
Nil
119119
else
120120
def stripComment(s: String) = s.indexOf('#') match { case -1 => s case i => s.substring(0, i) }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import core.Contexts.{Context, ctx}
55
object Printers {
66

77
class Printer {
8-
def println(msg: => String): Unit = System.out.nn.println(msg)
8+
def println(msg: => String): Unit = System.out.println(msg)
99
}
1010

1111
object noPrinter extends Printer {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dotty.tools.dotc
22
package config
33

4-
import scala.language.unsafeNulls
54
import dotty.tools.dotc.config.PathResolver.Defaults
65
import dotty.tools.dotc.config.Settings.{Setting, SettingGroup, SettingCategory, Deprecation}
76
import dotty.tools.dotc.config.SourceVersion

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package config
44
import Settings.Setting.ChoiceWithHelp
55
import dotty.tools.backend.jvm.BackendUtils.classfileVersionMap
66
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile}
7-
import scala.language.unsafeNulls
87

98
object ScalaSettingsProperties:
109

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
package dotty.tools
44
package dotc.config
55

6-
import scala.language.unsafeNulls
7-
86
import scala.annotation.internal.sharable
97
import scala.util.{Try, Success, Failure}
108

@@ -82,20 +80,20 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu
8280
"The minor and revision parts are optional."
8381
))
8482

85-
def toInt(s: String) = s match {
83+
def toInt(s: String | Null) = s match {
8684
case null | "" => 0
87-
case _ => s.toInt
85+
case _ => s.nn.toInt
8886
}
8987

9088
def isInt(s: String) = Try(toInt(s)).isSuccess
9189

9290
import ScalaBuild.*
9391

94-
def toBuild(s: String) = s match {
92+
def toBuild(s: String | Null) = s match {
9593
case null | "FINAL" => Final
9694
case s if (s.toUpperCase.startsWith("RC") && isInt(s.substring(2))) => RC(toInt(s.substring(2)))
9795
case s if (s.toUpperCase.startsWith("M") && isInt(s.substring(1))) => Milestone(toInt(s.substring(1)))
98-
case _ => Development(s)
96+
case _ => Development(s.nn)
9997
}
10098

10199
try versionString match {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dotty.tools.dotc
22
package config
33

4-
import scala.language.unsafeNulls
5-
64
import core.Contexts.*
75

86
import dotty.tools.io.{AbstractFile, Directory, JarArchive, PlainDirectory}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ object MacroClassLoader {
1919
ctx.setProperty(MacroClassLoaderKey, makeMacroClassLoader(using ctx))
2020

2121
private def makeMacroClassLoader(using Context): ClassLoader = trace("new macro class loader") {
22-
import scala.language.unsafeNulls
23-
2422
val entries = ClassPath.expandPath(ctx.settings.classpath.value, expandStar=true)
2523
val urls = entries.map(cp => java.nio.file.Paths.get(cp).toUri.toURL).toArray
2624
val out = Option(ctx.settings.outputDir.value.toURL) // to find classes in case of suspended compilation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ object Names {
393393
// because asserts are caught in exception handlers which might
394394
// cause other failures. In that case the first, important failure
395395
// is lost.
396-
System.err.nn.println("Backend should not call Name#toString, Name#mangledString should be used instead.")
396+
System.err.println("Backend should not call Name#toString, Name#mangledString should be used instead.")
397397
Thread.dumpStack()
398398
assert(false)
399399
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object StdNames {
4242

4343
@sharable
4444
private val disallowed = java.util.regex.Pattern.compile("""[<>]""").nn
45-
def sanitize(str: String): String = disallowed.matcher(str).nn.replaceAll("""\$""").nn
45+
def sanitize(str: String): String = disallowed.matcher(str).replaceAll("""\$""").nn
4646
}
4747

4848
abstract class DefinedNames[N <: Name] {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class UnpicklingError(denot: Denotation, where: String, cause: Throwable)(using
246246
case cause: UnpicklingError => ""
247247
case _ =>
248248
if ctx.settings.YdebugUnpickling.value then
249-
cause.getStackTrace().nn.mkString("\n ", "\n ", "")
249+
cause.getStackTrace().mkString("\n ", "\n ", "")
250250
else "\n\nRun with -Ydebug-unpickling to see full stack trace."
251251
em"""Could not read definition $denot$where. Caused by the following exception:
252252
|$cause$debugUnpickling"""

compiler/src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package dotc
33
package core
44
package classfile
55

6-
import scala.language.unsafeNulls
7-
86
import java.lang.Float.intBitsToFloat
97
import java.lang.Double.longBitsToDouble
108
import java.io.{ByteArrayInputStream, DataInputStream}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object Texts {
7474
else appendIndented(that)(width)
7575

7676
private def lengthWithoutAnsi(str: String): Int =
77-
ansi.matcher(str).nn.replaceAll("").nn.length
77+
ansi.matcher(str).replaceAll("").length
7878

7979
def layout(width: Int): Text = this match {
8080
case Str(s, _) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ object GenericSignatures {
170170
def fullNameInSig(sym: Symbol): Unit = {
171171
assert(sym.isClass)
172172
val name = atPhase(genBCodePhase) { sanitizeName(sym.fullName).replace('.', '/') }
173-
builder.append('L').nn.append(name)
173+
builder.append('L').append(name)
174174
}
175175

176176
def classSig(sym: Symbol, pre: Type = NoType, args: List[Type] = Nil): Unit = {
@@ -215,7 +215,7 @@ object GenericSignatures {
215215

216216
// TODO revisit this. Does it align with javac for code that can be expressed in both languages?
217217
val delimiter = if (builder.charAt(builder.length() - 1) == '>') '.' else '$'
218-
builder.append(delimiter).nn.append(sanitizeName(sym.name))
218+
builder.append(delimiter).append(sanitizeName(sym.name))
219219
}
220220
else fullNameInSig(sym)
221221
}

presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ class CompilerSearchVisitor(
105105
override def isCancelled: Boolean = false
106106

107107
private def normalizePackage(pkg: String): String =
108-
pkg.replace("/", ".").nn.stripSuffix(".")
108+
pkg.replace("/", ".").stripSuffix(".")
109109

110110
end CompilerSearchVisitor

presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object SymbolProvider:
105105
catch case NonFatal(e) => Nil
106106

107107
private def normalizePackage(pkg: String): String =
108-
pkg.replace("/", ".").nn.stripSuffix(".")
108+
pkg.replace("/", ".").stripSuffix(".")
109109

110110
private def toSymbols(info: SymbolInfo.SymbolParts)(using Context): List[Symbol] =
111111
def collectSymbols(denotation: Denotation): List[Symbol] =

presentation-compiler/src/main/dotty/tools/pc/TastyUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object TastyUtils:
4040
end htmlTasty
4141

4242
private def tastyHtmlPageTitle(file: URI) =
43-
val filename = Paths.get(file).nn.getFileName().toString
43+
val filename = Paths.get(file).getFileName().toString
4444
s"TASTy for $filename"
4545

4646
private val standaloneHtmlStyles =

project/Build.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ object Build {
986986
// compiler is updated.
987987
// Then, the next step is to enable flexible types by default and reduce the use of
988988
// `unsafeNulls`.
989-
scalacOptions ++= Seq("-Yno-flexible-types"),
989+
// scalacOptions ++= Seq("-Yno-flexible-types"),
990990
packageAll := {
991991
(`scala3-compiler` / packageAll).value ++ Seq(
992992
"scala3-compiler" -> (Compile / packageBin).value.getAbsolutePath,
@@ -1377,10 +1377,10 @@ object Build {
13771377
.asScala3PresentationCompiler(NonBootstrapped)
13781378
lazy val `scala3-presentation-compiler-bootstrapped` = project.in(file("presentation-compiler"))
13791379
.asScala3PresentationCompiler(Bootstrapped)
1380-
.settings(
1381-
// Add `-Yno-flexible-types` flag for bootstrap, see comments for `bootstrappedDottyCompilerSettings`
1382-
Compile / scalacOptions += "-Yno-flexible-types"
1383-
)
1380+
// .settings(
1381+
// // Add `-Yno-flexible-types` flag for bootstrap, see comments for `bootstrappedDottyCompilerSettings`
1382+
// Compile / scalacOptions += "-Yno-flexible-types"
1383+
// )
13841384

13851385
def scala3PresentationCompiler(implicit mode: Mode): Project = mode match {
13861386
case NonBootstrapped => `scala3-presentation-compiler`

0 commit comments

Comments
 (0)