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

Make sure that the stacktrace is shown with -Ydebug-unpickling #19115

Conversation

nicolasstucki
Copy link
Contributor

New behaviour, tested on #18967

// Test.scala
def test: Option[Int] = ???
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala
-- Error: Test.scala:1:10 ----------------------------------------------------
1 |def test: Option[Int] = ???
  |          ^
  |Could not read definition class Option in 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 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 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 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 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.

sbt> scala3-bootstrapped/scalac -Ydebug-unpickling Test.scala
-- Error: Test.scala:1:10 ----------------------------------------------------
1 |def test: Option[Int] = ???
  |          ^
  |Could not read definition class Option in 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 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 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 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 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
  |    dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:186)
  |    dotty.tools.dotc.core.SymDenotations$BaseDataImpl.apply(SymDenotations.scala:2973)
  |    dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseData(SymDenotations.scala:1954)
  |    dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseClassSet(SymDenotations.scala:1970)
  |    dotty.tools.dotc.core.SymDenotations$ClassDenotation.isValueClass(SymDenotations.scala:2032)
  |    dotty.tools.dotc.core.SymUtils.isDerivedValueClass(SymUtils.scala:85)
  |    dotty.tools.dotc.core.TypeErasure$.dotty$tools$dotc$core$TypeErasure$$$erasureDependsOnArgs(TypeErasure.scala:74)
  |    ...

Old behaviour

sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala 
-- Error: Test.scala:1:10 ----------------------------------------------------
1 |def test: Option[Int] = ???
  |          ^
  |Could not read definition of class Option in /Users/nicolasstucki/Github/dotty/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)
  |An exception was encountered:
  |  dotty.tools.dotc.core.TypeError$$anon$1: Could not read definition of type IterableOnce in /Users/nicolasstucki/Github/dotty/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)
  |An exception was encountered:
  |  dotty.tools.dotc.core.TypeError$$anon$1: Could not read definition of trait IterableOnce in /Users/nicolasstucki/Github/dotty/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)
  |An exception was encountered:
  |  dotty.tools.dotc.core.TypeError$$anon$1: Could not read definition of trait Iterable in /Users/nicolasstucki/Github/dotty/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)
  |An exception was encountered:
  |  dotty.tools.dotc.core.TypeError$$anon$1: Could not read definition of trait Iterable in /Users/nicolasstucki/Github/dotty/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)
  |An exception was encountered:
  |  dotty.tools.dotc.core.CyclicReference: Cyclic reference involving trait Seq
  |Run with -Ydebug-unpickling to see full stack trace.
  |Run with -Ydebug-unpickling to see full stack trace.
  |Run with -Ydebug-unpickling to see full stack trace.
  |Run with -Ydebug-unpickling to see full stack trace.
  |Run with -Ydebug-unpickling to see full stack trace.
1 error found

sbt> scala3-bootstrapped/scalac t/Test.scala -Ydebug-unpickling
-- Error: t/Test.scala:1:10 ----------------------------------------------------
1 |def test: Option[Int] = ???
  |          ^
  |          Cyclic reference involving trait Seq
  |
  | longer explanation available when compiling with `-explain`
1 error found

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.

LGTM

@odersky odersky merged commit fe55cef into scala:main Dec 15, 2023
19 checks passed
@odersky odersky deleted the make-sure-that-the-stacktrace-is-shown-with-Ydebug-unpickling branch December 15, 2023 09:59
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
nicolasstucki added a commit that referenced this pull request Jan 3, 2024
We can override the sources of the standard library with cc annotation
in this project and generate a TASTy version of the standard library.

Usage:
```
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/testCompilation
sbt> scala3-bootstrapped/test
sbt> scala3-bootstrapped/run ...
```

```
sbt> scala2-library-cc/run diff
sbt> scala2-library-cc/run diff scala/Option.scala
sbt> scala2-library-cc/run diff scala/collection/immutable
```

### Current limitations

#### Empty self types in library
We need to override `Function1` and `PartialFunction` to remove their
empty self type. These cause some problem with capture checking. We need
to fix these cases. I will open an issue once we have a way to reproduce
it with this PR.

#### Cannot use the TASTy jar yet
There is a bug when we try to class load the captured checked library
from TASTy. These are due to some cyclic reference while unpickling the
TASTy.

<del>The current theory is that this due to the CC annotations in the
top-level classes.
If this is the case, we can fix this issue by adding these language
features as TASTy attributes (see #19033).</del>
This was wrong or only part of the problems. The current issue can be
reproduced with #19115.
WojciechMazur added a commit that referenced this pull request Jun 26, 2024
…ling`" to LTS (#20801)

Backports #19115 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
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.

3 participants