Skip to content

Fix #7110: Fix splice overload #8561

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

Merged
merged 5 commits into from
Apr 1, 2020

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Mar 17, 2020

To avoid wrong member selection when unpickling we must have qualifiers that have the same type as when it was pickled. This implies that we cannot expand the holes during unpickling as
the expansion of a qualifier could have a more precise type. To be able to unpickle a hole
without expanding it we must know its type, hence it must be pickled.

Once the pickled quote has been unpickled, we first replace all the type splices. After the
types are properly set we expand all the term holes.

Changes

  • Types of holes are pickled in TASTy
  • Pickled quotes are unpickled and then the holes are expanded
  • Improved debugging info for unpickled quotes

@nicolasstucki nicolasstucki self-assigned this Mar 17, 2020
@nicolasstucki nicolasstucki force-pushed the fix-splice-overload-2 branch 2 times, most recently from 36e74c5 to 3e3bb1d Compare March 20, 2020 13:39
@nicolasstucki nicolasstucki force-pushed the fix-splice-overload-2 branch 3 times, most recently from 37f0bff to b89405c Compare March 27, 2020 10:59
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Mar 27, 2020

test performance with #quotes please

@dottybot
Copy link
Member

dottybot commented Mar 27, 2020

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8561 to see the changes.

Benchmarks is based on merging with master (64d6536)

@scala scala deleted a comment from dottybot Mar 28, 2020
@scala scala deleted a comment from dottybot Mar 28, 2020
@nicolasstucki nicolasstucki force-pushed the fix-splice-overload-2 branch 3 times, most recently from fd5ec93 to 36253dc Compare March 31, 2020 07:54
@nicolasstucki
Copy link
Contributor Author

test performance with #quotes please

@dottybot
Copy link
Member

performance test scheduled: 3 job(s) in queue, 1 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8561/ to see the changes.

Benchmarks is based on merging with master (8a42819)

@nicolasstucki nicolasstucki force-pushed the fix-splice-overload-2 branch 2 times, most recently from be33572 to 789344e Compare March 31, 2020 15:17
To avoid wrong member selection when unpickling we must have qualifiers that have the same type as when it was pickled. This implies that we cannot expand the holes during unpickling as
the expansion of a qualifier could have a more precise type. To be able to unpickle a hole
without expanding it we must know its type, hence it must be pickled.

Once the pickled quote has been unpickled, we first replace all the type splices. After the
types are properly set we expand all the term holes.

Changes
* Types of holes are pickled in TASTy
* Pickled quotes are unpickled and then the holes are expanded
* Improved debugging info for unpickled quotes
@nicolasstucki
Copy link
Contributor Author

test performance with #quotes please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 1 running.

@nicolasstucki nicolasstucki marked this pull request as ready for review March 31, 2020 16:11
@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8561/ to see the changes.

Benchmarks is based on merging with master (8a42819)

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM

val Inlined(call, Nil, expnasion) = unpickled
val inlineCtx = inlineContext(call)
val expansion1 = spliceTypes(expnasion, splices)(using inlineCtx)
val expansion2 = spliceTerms(expansion1, splices)(using inlineCtx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Small opt: can we just do one pass for splicing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that was the first approach I tried. We need the types to be known when we expand the term holes as some of them may take some type parameters that the user inspects. Note that spliceTypes is a no-op if the quote does not have type splices.

apply(tp.widenTermRefExpr)
case tp =>
mapOver(tp)
}
Copy link
Contributor

@liufengyun liufengyun Apr 1, 2020

Choose a reason for hiding this comment

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

Will approximation of the hole type have consequences on member resolution in unpickling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the consequence is that when unpickling we use the same known bounds of the types to resolve members selection as was done in typed. This is the key to make sure they do not change.

// Make sure trees and positions are fully loaded
new TreeTraverser {
def traverse(tree: Tree)(implicit ctx: Context): Unit = traverseChildren(tree)
}.traverse(tree)
Copy link
Contributor

Choose a reason for hiding this comment

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

What will happen if we remove the code above? Maybe add a doc for consequences if the action is not taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some symbols and positions are not loaded early enough. Not sure why though. But it has been like that since the start. Dimitry mentioned the need for this for loading trees from tasty in general and we have keep this mechanism so far.

@nicolasstucki nicolasstucki requested a review from liufengyun April 1, 2020 12:25
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@nicolasstucki nicolasstucki merged commit 0bd0fcf into scala:master Apr 1, 2020
@nicolasstucki nicolasstucki deleted the fix-splice-overload-2 branch April 1, 2020 15:05
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