-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Splice hole with this capture #18385
Conversation
7d4f934
to
d9b7911
Compare
d9b7911
to
3f78147
Compare
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
3f78147
to
fb02cfc
Compare
// 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. |
There was a problem hiding this comment.
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?
fb02cfc
to
5877755
Compare
This PR tackles two similar but distinct issues in two different phases of the staging process.
refBindingMap
forthis
was inconsistent. The mapping did not distinguish between athis
type andthis
term because they have the same symbol. The solution is to split the mapping into types and terms.this
type from term. We use aEXPLICITtpt
(as in Splice hole with singleton captures #18357) to make sure aThisType
is unpickled as a type.Revisit #17138