-
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
Inconsistent export
of case classes' synthetic methods
#13228
Comments
This looks according to do spec to me. Summary: When dealing with case classes, stay away from wildcard exports. The results might be unintuitive. As usual, explicit is better. |
Can we at least issue a compiler warning for wildcard exports of case classes? Seems it might be a source of many confusions. |
I think that would be a job for a linter. Compiler warnings have diminishing and at some point negative returns. |
I think we do have a problem here because the result is not consistent under separate compilation, if I split the example into a file containing just: case class User(name: String) which I then compile, followed by compiling the rest of the example I get: RegisteredUser(Id,User(Name))
false
false
false because the PostTyper phase added synthetic definitions for canEqual/productXXX and wildcard exports filters synthetic definitions out: https://github.com/lampepfl/dotty/blob/9e8d5c55153fdbe0d3f78d661cb3b51113403128/compiler/src/dotty/tools/dotc/typer/Namer.scala#L1159 |
@smarter Fair point :-) |
Compiler version
3.0.1
Minimized code
Output
Expectation
According to @bishabosha
and
@kubukoz
[1] https://twitter.com/bishabosha/status/1421803014722052098
[2] https://twitter.com/kubukoz/status/1421810894967906304
The text was updated successfully, but these errors were encountered: