Inconsistent `export` of case classes' synthetic methods
See original GitHub issueCompiler version
3.0.1
Minimized code
case class User(name: String)
case class RegisteredUser(id: String, data: User) {
export data.*
}
@main def app() =
println(RegisteredUser("Id", User("Name"))) // RegisteredUser(Name)
println(RegisteredUser("Id", User("Name")).canEqual(User("Name"))) // True
// The rest works as expected
println(RegisteredUser("Id", User("Name")) == User("Name")) // False
println(RegisteredUser("Id", User("Name")).hashCode == User("Name").hashCode) // False
Output
RegisteredUser(Name)
true
false
false
Expectation
RegisteredUser(Id, User(Name))
false
false
false
According to @bishabosha
So what’s happening here is that
productArity
andproductElement
are delegated todata
field, (those methods are called from toString) but equals, hashCode, toString are not exported. (problematic thatcanEqual
is also exported)
and @kubukoz
Yeah, strange. toString defers to productPrefix I think, that should probably have been exported as well…
[1] https://twitter.com/bishabosha/status/1421803014722052098 [2] https://twitter.com/kubukoz/status/1421810894967906304
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
COMPLIANCE GUIDELINES: HOW TO DEVELOP AN ...
These Guidelines promote good export compliance practices and have been developed to help companies like yours create an effective EMCP that will minimize...
Read more >Aggregated Damages in a Class Action Suit Found ...
In a case of first impression, a Pennsylvania federal court determined that class action damages based on a trading model that aggregated damages...
Read more >Find and fix inconsistent B-tree indexes - Google Cloud
Inconsistencies in database indexes can occur for a variety of reasons including software defects, hardware issues, or underlying changes in behavior such ...
Read more >Case Classes | Tour of Scala
Case classes are like regular classes with a few key differences which we will go over. Case classes are good for modeling immutable...
Read more >REASONING WITH INCONSISTENT ONTOLOGIES ...
Given a query posed w.r.t. an inconsistent ontology, a dialectical analysis will be performed on a DeLP program obtained from such an ontology, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
which I then compile, followed by compiling the rest of the example I get:
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 😃