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

Disable type simplify in unpickler #14506

Merged
merged 2 commits into from Feb 17, 2022
Merged

Conversation

noti0na1
Copy link
Member

Type simplify may produce different type on SkelomType in AndType.

WIthout the fix:

class A

type B = A

def f[T](x: T): x.type & T = ???

def g = {
  var a: B = ???
  f[A](a)
}

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

Exception in thread "main" class dotty.tools.dotc.reporting.Diagnostic$Error at ?: pickling difference for module class Stest$package$ 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:148)
        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)class dotty.tools.dotc.reporting.Diagnostic$Error at ?: pickling difference for module class Stest$package$ in Stest.scala, for details:

  diff before-pickling.txt after-pickling.txt while compiling Stest.scala
        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:226)
        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:237)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:245)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:254)
        at dotty.tools.dotc.Run.compileSources(Run.scala:187)
        at dotty.tools.dotc.Run.compile(Run.scala:171)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)

before-pickling.txt

<package <empty>.type {
  final lazy module val Stest$package: Stest$package = 
    <<<new Stest$package:Stest$package>:((): Stest$package)>():Stest$package>
  @SourceFile(<"Stest.scala":("Stest.scala" : String)>) final module class 
    Stest$package
  () extends <<<new Object:Object>:((): Object)>():Object> { 
    this: <Stest$package:Stest$package>.type =>
    private def writeReplace(): scala.AnyRef = 
      <
        <
          <new scala.runtime.ModuleSerializationProxy:
            scala.runtime.ModuleSerializationProxy
          >
        :((moduleClass: Class[?]): scala.runtime.ModuleSerializationProxy)>
      (
        <classOf[Stest$package.type]:
          (classOf[Stest$package.type] : Class[Stest$package.type])
        >
      ):scala.runtime.ModuleSerializationProxy>
    type B = A
    def f[T >: scala.Nothing <: scala.Any](x: T): <x:T>.type & T = 
      <scala.Predef.???:=> scala.Nothing>
    def g: Stest$package.B = 
      <
        {
          var a: Stest$package.B = <scala.Predef.???:=> scala.Nothing>
          <<<Stest$package.f:([T](x: T): x.type)>[A]:((x: A): x.type)>(
            <a:Stest$package.B>
          ):A>
        }
      :A>
  }
}:<empty>.type>

diff before-pickling.txt after-pickling.txt

29c29
<           ):A>
---
>           ):Stest$package.B>

(the error message is printed twice for some reason?)

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less magic in unpickling - I like it!

Great to see that we could simply drop that.

Test should better be named pickleSkolem.scala.

@odersky odersky merged commit 7015237 into scala:main Feb 17, 2022
@odersky odersky deleted the fix-pickling branch February 17, 2022 16:34
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants