Skip to content

Commit c8b4100

Browse files
committed
Re-enable explicit nulls in compiler
1 parent b65f2d5 commit c8b4100

File tree

11 files changed

+16
-14
lines changed

11 files changed

+16
-14
lines changed

compiler/src/dotty/tools/MainGenericCompiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ object MainGenericCompiler {
131131
val tStopAtLvl="-XX:TieredStopAtLevel=1"
132132
println(s"ignoring deprecated -Oshort flag, please add `-J$addTC` and `-J$tStopAtLvl` flags manually")
133133
process(tail, settings)
134-
case javaOption(stripped) :: tail =>
134+
case javaOption(stripped: String) :: tail =>
135135
process(tail, settings.withJavaArgs(stripped))
136-
case javaPropOption(opt, value) :: tail =>
136+
case javaPropOption(opt: String, value: String) :: tail =>
137137
process(tail, settings.withJavaProps(opt -> value))
138138
case arg :: tail =>
139139
process(tail, settings.withResidualArgs(arg))

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object MainGenericRunner {
143143
processArgs(tail, settings.noSave)
144144
case "-with-compiler" :: tail =>
145145
processArgs(tail, settings.withCompiler)
146-
case (o @ javaOption(striped)) :: tail =>
146+
case (o @ javaOption(striped: String)) :: tail =>
147147
processArgs(tail, settings.withJavaArgs(striped).withScalaArgs(o))
148148
case (o @ scalaOption(_*)) :: tail =>
149149
val remainingArgs = CommandLineParser.expandArg(o) ++ tail

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ object Comments {
404404
val raw = ctx.docCtx.flatMap(_.docstring(sym).map(_.raw)).getOrElse("")
405405
defs(sym) ++= defines(raw).map { str =>
406406
val start = skipWhitespace(str, "@define".length)
407-
val (key, Trim(value)) = str.splitAt(skipVariable(str, start)): @unchecked
407+
val (key, Trim(value: String)) = str.splitAt(skipVariable(str, start)): @unchecked
408408
variableName(key.drop(start)) -> value.replaceAll("\\s+\\*+$", "")
409409
}
410410
}

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3000,7 +3000,7 @@ class MissingImplicitArgument(
30003000
val idx = paramNames.indexOf(name)
30013001
if (idx >= 0) Some(i"${args(idx)}") else None
30023002
"""\$\{\s*([^}\s]+)\s*\}""".r.replaceAllIn(raw, (_: Regex.Match) match
3003-
case Regex.Groups(v) => quoteReplacement(translate(v).getOrElse("?" + v)).nn
3003+
case Regex.Groups(v: String) => quoteReplacement(translate(v).getOrElse("?" + v)).nn
30043004
)
30053005

30063006
/** @param rawMsg Message template with variables, e.g. "Variable A is ${A}"

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ object Scala3:
382382
object LocalSymbol:
383383

384384
def unapply(symbolInfo: SymbolInformation): Option[Int] = symbolInfo.symbol match
385-
case locals(ints) =>
385+
case locals(ints: String) =>
386386
val bi = BigInt(ints)
387387
if bi.isValidInt then
388388
Some(bi.toInt)

compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
126126
def at(g: SpecGroup): Int = descriptor.start(g.ordinal)
127127
def end(g: SpecGroup): Int = descriptor.end(g.ordinal)
128128
def offset(g: SpecGroup, i: Int = 0): Int = at(g) + i
129-
def group(g: SpecGroup): Option[String] = Option(descriptor.group(g.ordinal))
129+
def group(g: SpecGroup): Option[String] =
130+
// Unable to use @experimental fromNullable now
131+
Option(descriptor.group(g.ordinal)).asInstanceOf[Option[String]]
130132
def stringOf(g: SpecGroup): String = group(g).getOrElse("")
131133
def intOf(g: SpecGroup): Option[Int] = group(g).map(_.toInt)
132134

compiler/src/dotty/tools/repl/ParseResult.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ object ParseResult {
180180
val sourceCode = source.content().mkString
181181
sourceCode match {
182182
case "" => Newline
183-
case CommandExtract(cmd, arg) => {
183+
case CommandExtract(cmd: String, arg: String) => {
184184
val matchingCommands = commands.filter((command, _) => command.startsWith(cmd))
185185
matchingCommands match {
186186
case Nil => UnknownCommand(cmd)

compiler/src/dotty/tools/scripting/Main.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object Main:
7878
writer.close()
7979
end writeJarfile
8080

81-
def pathsep = sys.props("path.separator")
81+
def pathsep: String = sys.props("path.separator").nn
8282

8383
extension(path: String) {
8484
// Normalize path separator, convert relative path to absolute
@@ -102,4 +102,4 @@ object Main:
102102
def secondChar: String = path.take(2).drop(1).mkString("")
103103
}
104104

105-
lazy val userDir = sys.props("user.dir").norm
105+
lazy val userDir: String = sys.props("user.dir").nn.norm

compiler/src/dotty/tools/scripting/StringDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StringDriver(compilerArgs: Array[String], scalaSource: String) extends Dri
3131
try
3232
val classpath = s"${ctx.settings.classpath.value}${pathsep}${sys.props("java.class.path")}"
3333
val classpathEntries: Seq[Path] = ClassPath.expandPath(classpath, expandStar=true).map { Paths.get(_) }
34-
sys.props("java.class.path") = classpathEntries.map(_.toString).mkString(pathsep)
34+
sys.props("java.class.path") = classpathEntries.map(_.toString).mkString(pathsep.nn)
3535
detectMainClassAndMethod(outDir, classpathEntries, scalaSource) match
3636
case Right((mainClass, mainMethod)) =>
3737
mainMethod.invoke(null, Array.empty[String])

library/src/scala/Predef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ object Predef extends LowPriorityImplicits {
517517
@inline implicit def floatArrayOps(xs: Array[Float]): ArrayOps[Float] = new ArrayOps(xs)
518518
@inline implicit def intArrayOps(xs: Array[Int]): ArrayOps[Int] = new ArrayOps(xs)
519519
@inline implicit def longArrayOps(xs: Array[Long]): ArrayOps[Long] = new ArrayOps(xs)
520-
@inline implicit def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps(xs)
520+
@inline implicit def refArrayOps[T <: AnyRef | Null](xs: Array[T]): ArrayOps[T] = new ArrayOps(xs)
521521
@inline implicit def shortArrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps(xs)
522522
@inline implicit def unitArrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps(xs)
523523

0 commit comments

Comments
 (0)