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.values is confused by methods returning Val instances #3616

Closed
scabug opened this issue Jun 28, 2010 · 8 comments
Closed

Enumeration.values is confused by methods returning Val instances #3616

scabug opened this issue Jun 28, 2010 · 8 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jun 28, 2010

object X extends Enumeration {
    val Y = Value
}
object Fruit extends Enumeration {
    val x = X.Y
    val A,B,C = Value
}
scala> Fruit.values
res0: Fruit.ValueSet = object$$Fruit.ValueSet(x, B, C)
@scabug
Copy link
Author

scabug commented Jun 28, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3616?orig=1
Reporter: Thomas Jung (thomas jung)
See #5211
Attachments:

  • enum.scala (created on Jun 29, 2010 10:35:59 AM UTC, 208 bytes)

@scabug
Copy link
Author

scabug commented Jun 29, 2010

@dragos said:
Paul, can you have a look?

@scabug
Copy link
Author

scabug commented Jun 29, 2010

@harrah said:
I could not reproduce this with trunk, although I could believe the issue is real from looking at the source for Enumeration. I tried with defining X and Fruit both inside and outside the REPL and also reordering x.

Unless someone else can reproduce it, what version of Scala and Java and can you post a full example that runs outside the REPL?

@scabug
Copy link
Author

scabug commented Jun 29, 2010

Thomas Jung (thomas jung) said:
The original version was 2.8.0.RC5 but I can reproduce it with 2.8.0.RC6.

Welcome to Scala version 2.8.0.RC6 (Java HotSpot(TM) Client VM, Java 1.6.0_18).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object X extends Enumeration {
     |     val Y = Value
     | }
defined module X

scala> object Fruit extends Enumeration {
     |     val x = X.Y
     |     val A,B,C = Value
     | }
defined module Fruit

scala> Fruit.values
res0: Fruit.ValueSet = object$$Fruit.ValueSet(x, B, C)

@scabug
Copy link
Author

scabug commented Jun 30, 2010

@paulp said:
(In r22446) Enumeration fixes. There was no way to do reflection-based naming
correctly simply by inspecting method signatures (because a Value from
a different Enumeration stored in a val looks identical to one from
this Enumeration) so I have Value store the outer Enum for comparison
purposes. This won't make anything new uncollectable because they
already have an $$outer pointing there. This also simplified the
reflection logic: it's an eq test rather than a series of heuristics.

Closes #3616, #3615. Review by phaller.

@scabug
Copy link
Author

scabug commented Sep 27, 2010

phmietti said:
The inspection seems to be broken still in 2.8.1.RC1. it works if I define the name for Value but breaks if the name is not defined.

Welcome to Scala version 2.8.1.RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object X extends Enumeration {
     | val a, b = Value 
     | }
defined module X

scala> object Y extends Enumeration {
     | val a = Value("a")
     | val b = Value("b")
     | }
defined module Y

scala> X.values
res0: X.ValueSet = X.ValueSet(a, b)

scala> X.values
res1: X.ValueSet = X.ValueSet(a, b, Value)

scala> Y.values
res2: Y.ValueSet = Y.ValueSet(a, b)

scala> Y.values
res3: Y.ValueSet = Y.ValueSet(a, b)

@scabug
Copy link
Author

scabug commented Dec 26, 2010

@hubertp said:
That one seems to be a duplicate of #3687 (see comments of that ticket). It might be actually that this is the other way around, but it would be nice to keep things in one place. Assigning to myself as I was appointed to fix enumeration bugs.

@scabug
Copy link
Author

scabug commented Jan 4, 2011

@hubertp said:
(In r23893) Closes #3687, #3719, #3950, #3616. Plus removed some deprecated stuff for 2.9. 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