-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #7048: Check for splice stability #8097
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
Conversation
780038e
to
c3ec5d3
Compare
c3ec5d3
to
e29c481
Compare
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.
Otherwise, LGTM
{ | ||
val s = '{Option.empty[${T}]} | ||
val r = '{identity($s)} // works | ||
val r2 = '{identity(${s: Expr[Option[T]]})} // error // error |
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.
It's not obvious why this is not accepted by the check.
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.
32 | val r2 = '{identity[Option[T]](${s: Expr[Option[T]]})} // error // error
| ^^^^^^^^^^^^^^^^^^^^^
| (Test.this.given_Type_T : => quoted.Type[Test.this.T]) is not stable
All these can be fixed by making the given
stable
val getT: Type[T] = T // need this to avoid getting `null`
given getT.type = getT
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.
Added an extra test for it
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.
Why it has to be stable?
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.
Type splices require a stable prefix to be correctly encoded. It also avoids having to deal with side effects in the transformation performed in ReifyQuotes
. Most code receives the quoted type as a parameter and hence is stable.
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.
It's a restriction in TASTy? This is unprecedented in Scala, as usually only the path in types needs to be stable.
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.
This is a path in a type. A type that is inferred and then healed.
No description provided.