Open BarkingBad opened 2 years ago
Nice minimization
The order in which they are loaded seems to be important. If I reverse the file list it works.
Do you mean a list of tasty files?
EDIT: Ah, yes, indeed. I didn't see that
Slightly disentangled example
package bug
class Foo(x: Any)
trait RawXml:
class Value
object Body extends Foo(Text.apply(null)), RawXml
object Text:
def apply(body: Body.Value) = ???
This one fails when compiling Body
alone from TASTy.
This test can be added to tests/pos/i13814.scala
and run with testCompilation
I am not really sure how to fix this, since I have no experience with -from-tasty. Was there a specific reason to assign this to me?
Also: why does the title say "Cycle loading extends arguments from TASTy"? I don't see a cycle?
Also: why does the title say "Cycle loading extends arguments from TASTy"? I don't see a cycle?
object Body extends RawXml(Tei(null).namespace)
Tei
takes a Text
field which has a parameter of Body.Value
(where Body.Value
is inherited from RawXml
)
@odersky, this is not a -from-tasty
only issue anymore. It also happens in plain testCompilation
during the pickling tests. scalac tests/pos/i13814.scala -Ytest-pickler
with the example code is enough to trigger the issue.
As I understand it, when we unpickle Body
we need to unpickle the extends clause to be able to know the members of Body
. But to unpickle this extends we need to resolve Text.apply
which requires Body.Value
. But this member has not yet been added to Body
as we haven't finished unpickling the extends clasue of Body
and we haven't added RawXML
as one of the parents.
Looks like a duplicate of #12872.
Indeed, looks like the cause is similar to #12872. But it fails in a different way, in #12872 we detect the cycle while here we fail to see a symbol that should be there while unpickling.
Ok, reassigning to @bishabosha together with #12872, as I won't have time to work on this for the next month or so.
Compiler version
Scala compiler version 3.1.1-RC1-bin-SNAPSHOT-git-8947f38 -- Copyright 2002-2021, LAMP/EPFL
Minimized code
Then run:
Output: compiles successfully
Then run:
Output:
Expectation
Compiles successfully
Disclaimer
I know this minimization is not very obvious but it is as most self-contained as I could achieve. The error comes from opentorah project and has been reported at Gradle. The sbt reproduction can be found at this branch https://github.com/BarkingBad/opentorah/blob/repro/base/src/main/scala/org/opentorah/tei/Body.scala though as you can see you can reproduce it using the compiler from dotty directly.