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

Cannot load Scala 2 library TASTy with CC annotations #19398

Closed
nicolasstucki opened this issue Jan 8, 2024 · 1 comment · Fixed by #19425
Closed

Cannot load Scala 2 library TASTy with CC annotations #19398

nicolasstucki opened this issue Jan 8, 2024 · 1 comment · Fixed by #19425
Assignees
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Minimized example

// Test.scala
def test: Option[Int] = Some(1)
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala

See http://dotty.epfl.ch/docs/contributing/testing.html#scala-2-library-tasty-tests-1 for info on using the Scala 2 TASTy library.

Output

-- Error: Test.scala:1:10 ----------------------------------------------------
1 |def test: Option[Int] = Some(1)
  |          ^
  |Could not read definition class Option in ./scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.0-RC1-bin-SNAPSHOT.jar(scala/Option.tasty). Caused by the following exception:
  |dotty.tools.dotc.core.UnpicklingError: Could not read definition type IterableOnce in ./scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.0-RC1-bin-SNAPSHOT.jar(scala/package.tasty). Caused by the following exception:
  |dotty.tools.dotc.core.UnpicklingError: Could not read definition trait IterableOnce in ./scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.0-RC1-bin-SNAPSHOT.jar(scala/collection/IterableOnce.tasty). Caused by the following exception:
  |dotty.tools.dotc.core.UnpicklingError: Could not read definition trait Iterable in ./scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.0-RC1-bin-SNAPSHOT.jar(scala/collection/immutable/Iterable.tasty). Caused by the following exception:
  |dotty.tools.dotc.core.UnpicklingError: Could not read definition trait Iterable in ./scala2-library-cc-tasty/../out/bootstrap/scala2-library-cc-tasty/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala2-library-cc-tasty_3-3.4.0-RC1-bin-SNAPSHOT.jar(scala/collection/Iterable.tasty). Caused by the following exception:
  |dotty.tools.dotc.core.CyclicReference: Cyclic reference involving trait Seq
  |
  |Run with -Ydebug-unpickling to see full stack trace.
1 error found
@odersky
Copy link
Contributor

odersky commented Jan 12, 2024

What needs to be done if the library is changed:

scala2-library-cc/clean
scala2-library-cc-tasty/clean
scala2-library-cc/compile

set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
scala3-bootstrapped/scalac Test.scala // + options

odersky added a commit that referenced this issue Jan 14, 2024
Fixes #19398 

Clean up the logic how we infer self types, and add a new clause:

> If we have an externally extensible class that itself does not have a
declared self type itself and also not in any of its base classes,
assume {cap} as the self type. Previously we would install a capture
set but then check after the fact that that capture set is indeed {cap}.
So it's less verbose to just assume that from the start.
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants