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.maxId reporting wrong value? #3687
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3687?orig=1 |
@paulp said: |
Eduardo Moritz Cavalcanti (eduardocavalcanti) said: |
@lrytz said: scala> object t extends Enumeration { val a, b = Value }
defined module t
scala> t.values
res0: t.ValueSet = t.ValueSet(a, b)
scala> t.values
res1: t.ValueSet = t.ValueSet(a, b, Value) |
Eduardo Moritz Cavalcanti (eduardocavalcanti) said: The second situation reported affects values.size: scala> object t extends Enumeration { val a, b = Value } defined module t scala> t.values.size res0: Int = 2 scala> t.values.size res1: Int = 2 scala> t.values res2: t.ValueSet? = t.ValueSet?(a, b) scala> t.values.size res3: Int = 3 scala> t.values res4: t.ValueSet? = t.ValueSet?(a, b, Value) Regards |
Trond Olsen (tolsen) said: Here's a print dump: populateNameMap:enter nmap='Map()'
populateNameMap name='a' m='public scalatest.Enumeration$$Value line4$$object$$$$iw$$$$iw$$$$iw$$t$$.a()' value='0'
populateNameMap declaringClass='class line4$$object$$$$iw$$$$iw$$$$iw$$t$$'
populateNameMap name='b' m='public scalatest.Enumeration$$Value line4$$object$$$$iw$$$$iw$$$$iw$$t$$.b()' value='1'
populateNameMap declaringClass='class line4$$object$$$$iw$$$$iw$$$$iw$$t$$'
populateNameMap name='Value' m='public final scalatest.Enumeration$$Value scalatest.Enumeration.Value()' value='2'
populateNameMap declaringClass='class scalatest.Enumeration'
populateNameMap:exit nmap='Map(2 -> Value, 1 -> b, 0 -> a)' A quick fix could be just to filter away the method from the Enumeration class: private def populateNameMap() {
...
val methods = getClass.getMethods filter (m => m.getParameterTypes.isEmpty && classOf[Value].isAssignableFrom(m.getReturnType) && classOf[Enumeration] != m.getDeclaringClass)
...
} |
Trond Olsen (tolsen) said: |
Steve Jenson (stevej) said: $$ scala scala> object Blar extends Enumeration { scala> println(Blar.values) scala> println(Blar.values) |
Pablo Oliveira (pablo) said: |
Please verify if it is a bug:
Scaladoc defines Enumeration.maxId as:
"The highest integer amongst those used to identify values in this enumeration."
In the case below, should not maxId be 3 instead of 4?
Thank you.
The text was updated successfully, but these errors were encountered: