-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Inliner improvements #6218
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
Inliner improvements #6218
Conversation
No need to enter new bindings into a context, since all references are symbolic.
Avoids clutter in traces if staging is not relevant
- Don't destructively update the symbol of a case binding. This does not work reliably as the old info may flow into cached types. - Instead, create new case binding symbols and substitute old for new.
Need to take current context instead of global Inliner context.
The previous treatment could go wrong by confusing `bindings` and `termBindings` in a recursive step. test case: run/typeclass-derivation2c.scala
This leads to better generated code. Downside is a slight increase in the code of the deriving typeclasses.
ValueOf would happily return a value for non-value types, e.g. valueOf[String]. This would crash the backend later. This commit replaces the crash with a type error. Ideally, though, this should work as expected in inlined code.
Use the companion objects instead.
run/typeclass-derivation2c.scala is a worked out strawman that illustrates a feasible code generation strategy for typeclass derivation. It would be good to have the input of everyone involved before potentially proceeding to an implementation of these generation patterns. For more details, see: #6153 (comment) |
This needs a technical review whether the bug fixes and improvements in the inliner make sense. For the purpose of this review we can treat the new typeclass-derivation{a|b}.scala files simply as tests. We should separately discuss whether this is the scheme that should be implemented by the compiler. I propose we do that second discussion in #6153. I believe it's best to do the review by commit. |
@odersky I'm having trouble figuring out what the bugfixes and/or inliner improvements actually are here. Can you briefly summarise? |
Merging this PR broke the CI: http://dotty-ci.epfl.ch/lampepfl/dotty/12073/4
|
Ahh, right ... that became a pos test. |
This is some preliminary work to improve the Inliner to allow a larger set of idioms to be used in typeclass derivation. The idioms are tried in typeclass-derivation2{b|c}.scala, which serve as test-beds for now.