Closed
Description
Compiler 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