-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle leading given parameters in inline unapplies #13158
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
6395973
to
5b2ba2c
Compare
5b2ba2c
to
caab325
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.
This makes the code considerably more obscure. So it would have to be commented much better.
But that brings me to the other point. This considerably increases the complexity footprint of an already very complex method. So the question is: Is there an actual use case? Or could we just as well also disallow leading given parameter for inline unapplies?
I am worried that we create unpenetrable code that nobody will dare to touch anymore in the future.
val unappplySym = newSymbol(cls, sym.name.toTermName, Synthetic | Method, unapplyInfo, coord = sym.coord).entered | ||
val unapply = DefDef(unappplySym, argss => | ||
inlineCall(fun.appliedToArgss(argss).withSpan(unapp.span))(using ctx.withOwner(unappplySym)) | ||
val unapplySym = newSymbol(cls, sym.name.toTermName, Synthetic | Method, unapplyInfo, coord = sym.coord).entered |
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.
Where did the inlineCall go? Don't we need that?
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.
We don't need to expand it at this point, the inlining phase takes care of inlining the code.
For path-dependent unapplies. I can imagine the following case the the reflection API. object Foo:
inline def unapply(using Quotes)(term: quotes.reflect.Term): Option[...] = ... |
caab325
to
93fc08d
Compare
93fc08d
to
b539e55
Compare
b539e55
to
d3ff792
Compare
d3ff792
to
756bff9
Compare
We patch the crash in the compiler but do not support this feature yet. To support it see scala#13158 Fixes scala#12991
We patch the crash in the compiler but do not support this feature yet. To support it see scala#13158 Fixes scala#12991
Fixes #12991