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 captured types are listed before terms #17144

Closed
wants to merge 10 commits into from

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Mar 23, 2023

  • Refactor the hole used in the splicing phase to split targs from args.
  • Add new hole type that corresponds to the current pickled hole format. Future encoding will not use this kind of hole when we have a fix for Encoding of quote HOLE in TASTy #17137.

Common change from #17225, #17140 and #17120. One of them will be the fix for #17137. Probably #17225 will be the chosen solution.

@nicolasstucki nicolasstucki self-assigned this Mar 23, 2023
@nicolasstucki nicolasstucki force-pushed the splice-targ-order branch 3 times, most recently from 9aec519 to ac0c77c Compare March 24, 2023 08:34
@nicolasstucki nicolasstucki marked this pull request as ready for review March 24, 2023 13:48
@nicolasstucki nicolasstucki force-pushed the splice-targ-order branch 2 times, most recently from f42366d to 738c3aa Compare April 6, 2023 09:17
Comment on lines -199 to +202
val (refs, bindings) = refBindingMap.values.toList.unzip
val (typeRefs, typeBindings) = typeBindingMap.values.toList.unzip
val (termRefs, termBindings) = termBindingMap.values.toList.unzip
Copy link
Member

Choose a reason for hiding this comment

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

Not new in this PR, but Maps by default don't have a deterministic iteration order. Shouldn't a LinkedHashMap be used for determinism?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be better. I will use LinkedHashMap.

compiler/src/dotty/tools/dotc/ast/Trees.scala Outdated Show resolved Hide resolved
Comment on lines +1000 to +1007
* a single list. For backwards compatibility we read holes from tasty as
* if they had no targs and have only args. Therefore the args may contain
* type trees.
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to instead have the Unpickler separate the type args from the term args when unpickling an older tasty file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be ideal. Unfortunately, we cannot do that because we must pass all these arguments in the order they were listed. This is a consequence of the old format's interleaved type and term arguments. Specifically, the functions of ExprHole.V1 and ExprHole.V2 take these arguments in the order they are listed in the hole.

Comment on lines 979 to 980
* It is only used when encoding pickled quotes. These will be encoded
* as TastyQuoteHole when pickled.
Copy link
Member

Choose a reason for hiding this comment

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

I have read the documentation of Hole and TastyQuoteHole twice but I'm still confused on which one is used when, could this be described in more details, or could the documentation link to some other part of the codebase where this is explained?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the documentation

@smarter smarter assigned nicolasstucki and unassigned smarter Apr 11, 2023
@smarter smarter added the needs-minor-release This PR cannot be merged until the next minor release label Apr 11, 2023
@nicolasstucki nicolasstucki force-pushed the splice-targ-order branch 2 times, most recently from f0efb27 to 7285496 Compare April 12, 2023 08:46
@nicolasstucki nicolasstucki removed the needs-minor-release This PR cannot be merged until the next minor release label Apr 12, 2023
@nicolasstucki
Copy link
Contributor Author

This PR does not need a minor release. The minor release will be needed for the last step in #17225 where we change the representation of the hole in the TASTy format.

Comment on lines +66 to +67
* (U$2: Type[U], x1$: Expr[T], x2$: Expr[U]) => // body of this lambda does not contain references to x1 or x2
* (q: Quotes) ?=> f('{ @SplicedType type U$3 = $[ `0`: U | U$1 ]; g[U$3](${x1$}, ${x2$}) })
Copy link
Member

Choose a reason for hiding this comment

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

The parameter is called U$2 but I see U$1 used here, is that intentional? I also still think it'd be helpful to have some explanation of the $[ ... ] syntax somewhere

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

I think we need to figure out how to handle types that depend on terms (#17072 (comment)) to decide if we should merge this.

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.

2 participants