-
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
Derivation Works Without Derives Clause #16916
Comments
I agree that the documentation should not put The idea here is that each callsite of there is also another benefit: if there is recursion in "summoning" in the |
fixed by #17414 |
Please review the new doc pages at
also make sure your browser didn't cache the old page |
Compiler version
Scala 3.2.2
Minimized code
Output
// Compiles
Expectation
The snippet above is copied from the documentation of type class derivation in Scala 3 with one change. The documentation describes that we should use
Opt[+T] derives Eq
. However, the code above actually works without usingderives
.I'm not sure if this is a feature or a bug.
On the one hand automatic derivation of instances for sum and product types where instances exist for their elements is the dream. And it does appear that implementers of concrete data types can still provide their own instances in the companion object of the data types which have priority.
However, I can also see some people feeling that this is too powerful to globally derive instances for all data types regardless of whether they use
derives
to implement their intent to "opt in" to this.Just want to understand whether this is intended behavior that will continue to be supported in the future and whether this still reflects idiomatic usage of automatic derivation.
The text was updated successfully, but these errors were encountered: