Skip to content
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

Enumeration is extremely uncritical about equality #3186

Closed
scabug opened this issue Mar 17, 2010 · 6 comments
Closed

Enumeration is extremely uncritical about equality #3186

scabug opened this issue Mar 17, 2010 · 6 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Mar 17, 2010

It's hard to imagine this is what's intended for equals:

    override def equals(other: Any): Boolean = 
      other match {
        case that: Enumeration#Value => compare(that) == 0
        case _ => false
      } 
scala> object Dist1 extends Enumeration { val Mile, Foot, Inch = Value }
defined module Dist1

scala> object Dist2 extends Enumeration { val Kilometer, Millimeter, Parsec = Value }
defined module Dist2

scala> Dist1.Mile == Dist2.Kilometer
res0: Boolean = true
@scabug
Copy link
Author

scabug commented Mar 17, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3186?orig=1
Reporter: @paulp
See #5211

@scabug
Copy link
Author

scabug commented Mar 18, 2010

@paulp said:
I figured this must have been changed because of issues with type equality after deserialization, and a little searching reveals #2214. I had to address a similar problem with manifests which can be seen in r20079. I don't know why @serialize + readResolve is not working with enums, but the right fix is ensuring that they deserialize to the same object. The patch for 2214 instead of addressing the issue directly makes all enums with the same id equal, which I would say is adding a problem, not subtracting one.

@scabug
Copy link
Author

scabug commented Mar 23, 2010

@ingoem said:
Assigning to Philipp, since he closed #2214 originally. Feel free to reassign to meeting, Philipp.

@scabug
Copy link
Author

scabug commented Mar 23, 2010

@phaller said:
(In r21235) Fixes #3186. Closes #2214.

@scabug
Copy link
Author

scabug commented Mar 23, 2010

@phaller said:
(In r21236) Added test case for #3186. Closes #3186.

@scabug
Copy link
Author

scabug commented Mar 24, 2010

@phaller said:
(In r21245) Fixed the serialization test. Restored the test to use the semantics of Enumeration#equals in 2.7. Made caching of Enumeration objects thread safe. See #3186. Review by extempore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants