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.values is not referentially transparent #4334
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4334?orig=1 |
@Blaisorblade said: protected final def Value: Value = Value(nextId) (declared [https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_8_1_final/src//library/scala/Enumeration.scala#L131 here]) val methods = getClass.getMethods filter (m => m.getParameterTypes.isEmpty && classOf[Value].isAssignableFrom(m.getReturnType)) each of those methods is afterward invoked by Problems:
Should I provide a patch for 1) and 2)? |
@harrah said: |
@Blaisorblade said: |
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
In the interpreter, after loading this code:
gives the following output
=== What is the expected behavior? ===
MyEnum.values
should be referentially transparent:MyEnum.values == MyEnum.values
.=== What do you see instead? ===
MyEnum.values
gets an additional member namedValue
after the first use.=== Additional information ===
While I can understand that the implementation of Enumeration is quite complex, I'm worried that it still doesn't work. Additionally, the documentation should probably explain that it performs evil magic and should be used with care, i.e. by following the given pattern quite closely. A specification of "quite closely" would be most appreciated.
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: