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

Splice hole with this capture #18385

Closed

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Aug 11, 2023

This PR tackles two similar but distinct issues in two different phases of the staging process.

  • The mapping in refBindingMap for this was inconsistent. The mapping did not distinguish between a this type and this term because they have the same symbol. The solution is to split the mapping into types and terms.
  • We cannot distinguish a pickling a this type from term. We use a EXPLICITtpt (as in Splice hole with singleton captures #18357) to make sure a ThisType is unpickled as a type.

Revisit #17138

@nicolasstucki nicolasstucki self-assigned this Aug 11, 2023
@nicolasstucki nicolasstucki marked this pull request as ready for review August 14, 2023 11:05
@nicolasstucki nicolasstucki marked this pull request as draft August 14, 2023 11:06
@nicolasstucki nicolasstucki marked this pull request as ready for review August 16, 2023 08:22
@@ -203,6 +203,9 @@ class PickleQuotes extends MacroTransform {
private def getPicklableHoleType(tpe: Type, isStagedClasses: Symbol => Boolean)(using Context) =
new TypeOps.AvoidMap {
def toAvoid(tp: NamedType) = !isStagedClasses(tp.typeSymbol) && !isStaticPrefix(tp)
override def apply(tp: Type): Type = tp match
case tp: ThisType if tp.typeSymbol.isLocal => super.apply(tp.widen)
Copy link
Member

Choose a reason for hiding this comment

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

In regular AvoidMaps this isn't needed:
https://github.com/lampepfl/dotty/blob/ca6a80e3c7aef6b16304df20544c41a96556c834/compiler/src/dotty/tools/dotc/core/TypeOps.scala#L478-L482
Can you add a comment explaining why we need to do something different here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +211 to +213
// However, as we may be extracting a splice that contains a reference to
// a local class, we need to be careful to avoid the ThisType of the local
// class.
Copy link
Member

Choose a reason for hiding this comment

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

I guess I still don't really understand why we need to do this, what do we do with this approximated type exactly? What happens if we just use Any as an approximation?

@smarter smarter assigned nicolasstucki and unassigned smarter Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants