Closed
Description
An error similar to #14947
Minimized code
class C {
def g: String | Null = ???
def f =
import scala.language.unsafeNulls
try g catch case _ => ""
}
Output (click arrow to expand)
scalac -Xprint-types -Ytest-pickler -Yexplicit-nulls -color never Stest.scala
exception occurred while compiling Stest.scala
Exception in thread "main" class dotty.tools.dotc.reporting.Diagnostic$Error at ?: pickling difference for class C in Stest.scala, for details:
diff before-pickling.txt after-pickling.txt
at dotty.tools.dotc.report$.error(report.scala:63)
at dotty.tools.dotc.transform.Pickler.testSame(Pickler.scala:151)
at dotty.tools.dotc.transform.Pickler.testUnpickler$$anonfun$2(Pickler.scala:138)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:896)
at dotty.tools.dotc.transform.Pickler.testUnpickler(Pickler.scala:139)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:122)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:236)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:253)
at dotty.tools.dotc.Run.compileSources(Run.scala:186)
at dotty.tools.dotc.Run.compile(Run.scala:170)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.dotc.Driver.process(Driver.scala:195)
at dotty.tools.dotc.Driver.process(Driver.scala:163)
at dotty.tools.dotc.Driver.process(Driver.scala:175)
at dotty.tools.dotc.Driver.main(Driver.scala:205)
at dotty.tools.dotc.Main.main(Main.scala)
class dotty.tools.dotc.reporting.Diagnostic$Error at ?: pickling difference for class C in Stest.scala, for details:
diff before-pickling.txt after-pickling.txt while compiling Stest.scala
This is similar to the if
error before. The try
expression gets different types before and after pickling (String
and String | Null
).
Since the tree seems having correct language imports when unpickling (#14962), I guess the bug is from typing?
cc @odersky