Skip to content

remove some unnecessary unsafeNulls imports #23338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/config/CliCommand.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc
package config

import scala.language.unsafeNulls

import Settings.*
import core.Contexts.*
import printing.Highlighting
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package config

import scala.language.unsafeNulls

import WrappedProperties.AccessControl
import io.{ClassPath, Directory, Path}
import classpath.{AggregateClassPath, ClassPathFactory, JrtClassPath}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package dotc
package core
package classfile

import scala.language.unsafeNulls

import java.io.{DataInputStream, InputStream}
import java.nio.{BufferUnderflowException, ByteBuffer}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dotty.tools.dotc
package core
package tasty

import scala.language.unsafeNulls
import java.nio.file.{Path as JPath, Files as JFiles}
import java.nio.channels.ClosedByInterruptException
import java.io.DataOutputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc
package core.tasty

import scala.language.unsafeNulls

import core.Comments.Comment
import util.Spans.Span
import util.HashMap
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package dotc
package core
package tasty

import scala.language.unsafeNulls

import dotty.tools.tasty.{TastyBuffer, TastyFormat, TastyHash}
import dotty.tools.tasty.besteffort.BestEffortTastyFormat
import TastyFormat.*
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package core
package tasty

import java.util.UUID
import scala.language.unsafeNulls

import dotty.tools.tasty.{TastyFormat, TastyVersion, TastyBuffer, TastyReader, TastyHeaderUnpickler, UnpicklerConfig}
import dotty.tools.tasty.besteffort.{BestEffortTastyHeader, BestEffortTastyHeaderUnpickler}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc
package decompiler

import scala.language.unsafeNulls

import java.io.{OutputStream, PrintStream}
import java.nio.charset.StandardCharsets

Expand All @@ -26,8 +24,8 @@ class DecompilationPrinter extends Phase {
if (ctx.settings.outputDir.isDefault) printToOutput(System.out)
else {
val outputDir = ctx.settings.outputDir.value
var os: OutputStream = null
var ps: PrintStream = null
var os: OutputStream|Null = null
var ps: PrintStream|Null = null
try {
os = File(outputDir.fileNamed("decompiled.scala").path)(Codec.UTF8).outputStream(append = true)
ps = new PrintStream(os, /* autoFlush = */ false, StandardCharsets.UTF_8.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package decompiler

import scala.language.unsafeNulls

import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.*
import dotty.tools.dotc.core.tasty.TastyHTMLPrinter
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/fromtasty/Debug.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package fromtasty

import scala.language.unsafeNulls

import scala.util.control.NonFatal

import dotty.tools.io.Directory
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/fromtasty/TASTYRun.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package fromtasty

import scala.language.unsafeNulls

import io.{JarArchive, AbstractFile, Path, FileExtension}
import core.Contexts.*
import core.Decorators.em
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/fromtasty/TastyFileUtil.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc
package fromtasty

import scala.language.unsafeNulls

import dotty.tools.dotc.core.tasty.TastyClassName
import dotty.tools.dotc.core.StdNames.nme.EMPTY_PACKAGE
import dotty.tools.io.AbstractFile
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/interactive/Interactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package interactive

import scala.language.unsafeNulls

import scala.collection.*

import ast.{NavigateAST, Trees, tpd, untpd}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc
package printing

import scala.language.unsafeNulls

import dotty.tools.dotc.ast.untpd
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.StdNames.*
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/profile/ChromeTrace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

package dotty.tools.dotc.profile

import scala.language.unsafeNulls

import java.io.Closeable
import java.lang.management.ManagementFactory
import java.nio.file.{Files, Path}
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dotty.tools.dotc.profile

import scala.annotation.*
import scala.language.unsafeNulls

import java.io.{FileWriter, PrintWriter}
import java.nio.file.Paths
import java.lang.management.{ManagementFactory, GarbageCollectorMXBean, RuntimeMXBean, MemoryMXBean, ClassLoadingMXBean, CompilationMXBean}
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/profile/ThreadPoolFactory.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dotty.tools.dotc.profile

import scala.language.unsafeNulls

import java.util.concurrent.ThreadPoolExecutor.AbortPolicy
import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicInteger
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/quoted/TastyString.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dotty.tools.dotc.quoted

import scala.language.unsafeNulls

import java.util.Base64
import java.nio.charset.StandardCharsets.UTF_8

Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package reporting

import scala.language.unsafeNulls

import dotty.tools.dotc.config.Settings.Setting
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING}
Expand Down
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/reporting/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import config.SourceVersion
import cc.CaptureSet
import cc.Capabilities.*

import scala.language.unsafeNulls
import scala.annotation.threadUnsafe

/** ## Tips for error message generation
Expand Down Expand Up @@ -177,7 +176,7 @@ object Message:
case sym: Symbol =>
val info =
if (ctx.gadt.contains(sym))
sym.info & ctx.gadt.fullBounds(sym)
sym.info & ctx.gadt.fullBounds(sym).nn
else
sym.info
s"is a ${ctx.printer.kindString(sym)}${sym.showExtendedLocation}${addendum("bounds", info)}"
Expand Down Expand Up @@ -267,7 +266,7 @@ object Message:
case _ =>
super.funMiddleText(isContextual, isPure, refs)

override def toTextMethodAsFunction(info: Type, isPure: Boolean, refs: GeneralCaptureSet): Text =
override def toTextMethodAsFunction(info: Type, isPure: Boolean, refs: GeneralCaptureSet | Null): Text =
info match
case info: LambdaType =>
seen.openLambda(info)
Expand Down
5 changes: 0 additions & 5 deletions compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ extends SyntaxMsg(RepeatedModifierID) {
}

override def actions(using Context) =
import scala.language.unsafeNulls
List(
CodeAction(title = s"""Remove repeated modifier: "$modifier"""",
description = None,
Expand Down Expand Up @@ -887,7 +886,6 @@ extends Message(PatternMatchExhaustivityID) {
|"""

override def actions(using Context) =
import scala.language.unsafeNulls
val endPos = tree.cases.lastOption.map(_.endPos)
.getOrElse(tree.selector.endPos)
val startColumn = tree.cases.lastOption
Expand All @@ -910,7 +908,6 @@ extends Message(PatternMatchExhaustivityID) {


private def indent(text:String, margin: Int): String = {
import scala.language.unsafeNulls
" " * margin + text
}
}
Expand Down Expand Up @@ -1991,7 +1988,6 @@ class OnlyFunctionsCanBeFollowedByUnderscore(tp: Type, tree: untpd.PostfixOp)(us
|To convert to a function value, you need to explicitly write ${hl("() => x")}"""

override def actions(using Context) =
import scala.language.unsafeNulls
val untpd.PostfixOp(qual, Ident(nme.WILDCARD)) = tree: @unchecked
List(
CodeAction(title = "Rewrite to function value",
Expand Down Expand Up @@ -2021,7 +2017,6 @@ class MissingEmptyArgumentList(method: String, tree: tpd.Tree)(using Context)
}

override def actions(using Context) =
import scala.language.unsafeNulls
List(
CodeAction(title = "Insert ()",
description = None,
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dotty.tools
package dotc
package reporting

import scala.language.unsafeNulls

import core.*, Contexts.*, Decorators.*
import config.*
import printing.Formatting.*
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/sbt/ShowAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
package dotty.tools.dotc
package sbt

import scala.language.unsafeNulls

import xsbti.api.*

import scala.util.Try
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/scripting/Main.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dotty.tools.scripting

import scala.language.unsafeNulls

import java.io.File
import java.nio.file.{Path, Paths}
import dotty.tools.dotc.config.Properties.isWin
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/scripting/StringDriver.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dotty.tools.scripting

import scala.language.unsafeNulls

import java.nio.file.{ Files, Paths, Path }

import dotty.tools.dotc.Driver
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/scripting/Util.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dotty.tools.scripting

import scala.language.unsafeNulls

import java.nio.file.{ Path }
import java.io.File
import java.net.{ URLClassLoader }
Expand Down
Loading