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

Unresolved symbol while pickling quote #13732

Closed
nicolasstucki opened this issue Oct 12, 2021 · 3 comments · Fixed by #12540
Closed

Unresolved symbol while pickling quote #13732

nicolasstucki opened this issue Oct 12, 2021 · 3 comments · Fixed by #12540
Labels
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.1.0

Minimized code

import scala.quoted.*

def generateImpl(using q: Quotes): Expr[Unit] =
  '{ def runEffect[T]: T = ${ runEffectImpl[T] } }

inline def runEffectImpl[T: Type]: Expr[T] = ???

Related to #13563

Output

java.lang.AssertionError: assertion failed: unresolved symbols: type T (line 3) #13947 when pickling tests/pos-macros/i13563b.scala
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:777)
        at dotty.tools.dotc.quoted.PickledQuotes$.pickle(PickledQuotes.scala:167)
        at dotty.tools.dotc.quoted.PickledQuotes$.pickleQuote(PickledQuotes.scala:36)
        ...

Expectation

Should compile

@nicolasstucki
Copy link
Contributor Author

Workaround

- inline def runEffectImpl[T: Type]: Expr[T] = ???
+ def runEffectImpl[T: Type]: Expr[T] = ???

@anatoliykmetyuk anatoliykmetyuk added the Spree Suitable for a future Spree label Oct 15, 2021
@griggt
Copy link
Contributor

griggt commented Nov 17, 2021

@deniszo and I looked at this during today's spree. Some observations:

It seems that for some reason in this case, transformQuotation

https://github.com/lampepfl/dotty/blob/b311b4ecf84bf33dd387353a7dfb989e73f236ca/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala#L129-L141

wants to pickle a quote whose body consists solely of TypeTree[TypeRef(NoPrefix,type T)], and I get the impression that is somewhat nonsensical to pickle in isolation?

@griggt
Copy link
Contributor

griggt commented Nov 17, 2021

Is it expected that this issue can be solved separately from / without #12540 (or a similar reworking of quote pickling)?

@nicolasstucki nicolasstucki removed the Spree Suitable for a future Spree label Nov 19, 2021
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 7, 2022
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 28, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 14, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 24, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 11, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 19, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 19, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 19, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
michelou pushed a commit to michelou/dotty that referenced this issue Apr 25, 2022
Separate the logic that creates holes in quotes from the logic that
pickles the quotes. Holes are created in the `Splicer` phase and the
result of the transformation can be `-Ycheck`ed. Now, the `PickleQuotes`
phase only needs to extract the contents of the holes, pickle the quote
and put them into a call to `unpickleExprV2`/`unpickleTypeV2`.

We add `unpickleExprV2` to support some optimization in the encoding of
the pickled quote. Namely we removed an unnecessary lambda from the
arguments of the hole passed into the contents of the hole. By not
changing `unpickleExpr` the current compiler will be able to handle the
old encoding in binaries compiled with older compilers.
The `unpickleTypeV2` is just a version of `unpickleType` that does not
take the `termHole` parameter which is always `null`.
With `-Yscala-relese` 3.0 or 3.1, the compiler will generate calls to
the old `unpickleExpr`/`unpickleType`.

Fixes scala#8100
Fixes scala#12440
Fixes scala#13563
Fixes scala#14337
Fixes scala#14373
Closes scala#13732
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants