Skip to content
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

Pickling difference error with explicit nulls and unsafe nulls #14947

Closed
noti0na1 opened this issue Apr 15, 2022 · 0 comments · Fixed by #14962
Closed

Pickling difference error with explicit nulls and unsafe nulls #14947

noti0na1 opened this issue Apr 15, 2022 · 0 comments · Fixed by #14962

Comments

@noti0na1
Copy link
Member

I was trying to enable explicit nulls for all compiling. But I get several errors in BootstrappedOnlyCompilationTests.picklingWithCompiler test. See #14946

Minimized code

I am able to minimize some of the errors:

class C {
  def g: String | Null = ???

  def f =
    import scala.language.unsafeNulls
    if true then "" else g
}

Output

scalac -Xprint-types -Ytest-pickler -Yexplicit-nulls -color never Stest.scala

exception occurred while compiling Stest.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.scalaException 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)

before-pickling.txt

<package <empty>.type {
  @SourceFile(<"Stest.scala":("Stest.scala" : String)>) class C() extends <
    <<new Object:Object>:((): Object)>
  ():Object> {
    def g: scala.Predef.String | scala.Null = 
      <scala.Predef.???:=> scala.Nothing>
    def f: scala.Predef.String = 
      <
        {
          <import <<scala:scala>.language:scala.language>.unsafeNulls:
            <import>.type
          >
          <if <true:(true : scala.Boolean)> then <"":("" : String)> else 
            <<this:(C.this : C)>.g:=> scala.Predef.String | scala.Null>
          :String>
        }
      :String>
  }
}:<empty>.type>

diff before-pickling.txt after-pickling.txt

15c15
<           :String>
---
>           :String | scala.Null>
17c17
<       :String>
---
>       :String | scala.Null>

It seems the if expression gets different types before and after pickling?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants