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

Fix #16615 - crashes of path dependent types in spliced Type.of #16773

Merged
merged 2 commits into from
Feb 9, 2023

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Jan 27, 2023

Fixes #16615

Previously it was assumed that the type in Type.of could be captured as a whole, which meant that path dependent types for which a separate @SplicedType hole definitions were included in a block, would end up with missing references.

Now when find a block in Type.of, we try to analise all parts of the type separately, adding additional hole definitions to the block as necessary.
For types that can be captured as a whole (those which did not have a block generated previously, meaning they do not include any @SplicedType hole definitions), old method is used.

In essence, ended up replicating the trees proposed in the original issue thread, which were incredibly helpful.

@jchyb jchyb marked this pull request as ready for review January 27, 2023 11:14
@jchyb jchyb requested a review from nicolasstucki January 27, 2023 11:15
@nicolasstucki nicolasstucki self-assigned this Feb 2, 2023
Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Nice fix

compiler/src/dotty/tools/dotc/transform/Splicing.scala Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/transform/Splicing.scala Outdated Show resolved Hide resolved
tests/pos-macros/i16615.scala Show resolved Hide resolved
compiler/src/dotty/tools/dotc/transform/Splicing.scala Outdated Show resolved Hide resolved
tests/pos-macros/i16615.scala Outdated Show resolved Hide resolved
@nicolasstucki nicolasstucki assigned jchyb and unassigned nicolasstucki Feb 7, 2023
jchyb added 2 commits February 8, 2023 18:09
Previously it was assumed that the type in Type.of could be captured as
a whole, which meant that path dependent types for which a separate
@SplicedType hole definitions were included in a block, would end up
with missing references.

Now when find a block in Type.of, we try to analise all parts of the
type separately, adding additional hole definitions to the block as
necessary.
For types that can be captured as a whole (those which did not have
a block generated previously, meaning they do not include any
@SplicedType hole definitions), old method is used.
@nicolasstucki nicolasstucki merged commit 0ab89e6 into scala:main Feb 9, 2023
@nicolasstucki nicolasstucki deleted the fix/i16615 branch February 9, 2023 09:27
@Kordyjan Kordyjan added this to the 3.3.1 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.

Splice accessing path-dependent type with parameter crashes the compiler
3 participants