-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use canonical underlying type reference #10110
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
Use canonical underlying type reference #10110
Conversation
40b8801
to
8afec66
Compare
@@ -4,7 +4,7 @@ import scala.quoted._ | |||
object Test { | |||
def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ | |||
val y: t.Underlying = $x; | |||
${loop[t.Underlying]( // error | |||
${loop[t.Underlying]( |
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 was actually crashing with an assertion failure at
8afec66#diff-b3069d0753da3a2c12847b53d12eaf5d5003af1d6e6438c84f1dd5f6ef6a668eL218.
This also happens on master.
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 did not open an issue as the fix was straightforward.
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.
LGTM
} | ||
|
||
{ | ||
val s = '{Option.empty[${T}]} // works | ||
val s = '{Option.empty[T.Underlying]} // works |
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.
val s = '{Option.empty[T.Underlying]} // works | |
val s = '{Option.empty[T]} // works |
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 is equivalent but should not be changed to keep testing the same thing.
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.
For example, the second commit found the bug because I kept it as T.Underlying
.
val r1 = '{Option.empty[T.Underlying]} // works | ||
val r2 = '{Option.empty[List[T.Underlying]]} // works | ||
val r3 = '{summon[Type[T.Underlying]]} // error: is not stable | ||
val r4 = '{summon[T.Underlying <:< Any]} // error: is not 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 little surprising that List[T.Underlying]
works but summon[Type[T.Underlying]]]
is an 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.
This one was subtle.
[error] (Test.this.given_Type_T : => quoted.Type[Test.this.T]) is not a valid type witness, since it is not an immutable path
The issue is that given Type[T] = getT
is not stable. This is where I usually write given getT.type = getT
to not lose the path in the given.
The other cases happen to work because we only referred to T.Underlying
and never needed to head some type. This is the expected behavior.
else report.warning(msg, tree.srcPos) | ||
// if sourceVersion.isAtLeast(`3.1-migration`) then | ||
report.error(msg, tree.srcPos) | ||
// else report.warning(msg, tree.srcPos) |
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.
So we decide to enforce it in M1? That's fine, just make sure it's not an accidental change.
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 need to revert this change
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.
Reverted
8afec66
to
a779493
Compare
No description provided.