Skip to content

Commit da9cc38

Browse files
authored
Use more flexible types in dotty (#21608)
2 parents 16a67dc + eb269c8 commit da9cc38

File tree

77 files changed

+126
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+126
-168
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/MainGenericRunner.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/ClassfileWriters.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import dotty.tools.io.PlainFile.toPlainFile
1818
import BTypes.InternalName
1919
import dotty.tools.io.JarArchive
2020

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

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

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

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

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

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

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

Lines changed: 4 additions & 4 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 => ()
@@ -71,7 +71,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes:
7171
val locationAddendum =
7272
if pos1.source.path == pos2.source.path then ""
7373
else s" (defined in ${pos2.source.file.name})"
74-
def nicify(name: String): String = name.replace('/', '.').nn
74+
def nicify(name: String): String = name.replace('/', '.')
7575
if name1 == name2 then
7676
backendReporting.error(
7777
em"${nicify(name1)} and ${nicify(name2)} produce classes that overwrite one another", pos1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ object PostProcessorFrontendAccess {
146146
override def backendReporting: BackendReporting = {
147147
val local = localReporter.get()
148148
if local eq null then directBackendReporting
149-
else local.nn
149+
else local
150150
}
151151

152152
override object directBackendReporting extends BackendReporting {

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/Driver.scala

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ extends ImplicitRunInfo, ConstraintRunInfo, cc.CaptureRunInfo {
236236
try
237237
trackProgress(_.cancel())
238238
finally
239-
Thread.currentThread().nn.interrupt()
239+
Thread.currentThread().interrupt()
240240

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ object CaptureSet:
777777
extends Var(owner, initialElems):
778778

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

783783
/** The variable from which this variable is derived */
784784
def source: Var

0 commit comments

Comments
 (0)