You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to use this using a toplevel definition (no surrounding object) in my test source code:
valtestData=Seq(("blah", Color.Unknown), ("red", Color.Red(10)))
...
// use testData in a test
The process cannot see Color.Unknown in testData and I get an error at runtime:
[error] Test myapp.TestParsing.test_colors failed: java.lang.NoSuchFieldError: Unknown, took 0.003 sec
[error] at myapp.data$package$.actionDates(data.scala:139)
[error] at myapp.TestParsing.test_colors(TestParsing.scala:66)
[error] ...
If I move the definition of testData into the main project, vs the test itself, everything runs fine. Hence, no runtime error.
If I define Unknown as case Unknown(dummy: Int = -1) and use Color.Unknown() everywhere, everything runs fine. Using case Unknown() does not work.
I have seen this error before. But the consumer was in the same main application vs the test module so I do not think this is a test framework issue.
dotty 0.18
The text was updated successfully, but these errors were encountered:
aappddeevv
changed the title
enum case object not accessible in package object
enum case object not accessible in package object at runtime
Sep 22, 2019
I have also experienced this error in other code, where the bytecode points to the wrong location of an enum constant, but it only occurs under some incremental compilation that is hard to reproduce, If I compile from clean, it goes away.
Clean does not help me in my case. I used -Xprint:frontend but I could not see anything obvious that would cause this problem. It almost feels like an initialization order problem.
Uh oh!
There was an error while loading. Please reload this page.
I'm not sure I have the conditions completely nailed down for this but I can say that I get errors and they are fixed in a specific way.
When defining an enum with a case object vs a case class e.g.:
If I try to use this using a toplevel definition (no surrounding object) in my test source code:
The process cannot see Color.Unknown in testData and I get an error at runtime:
[error] Test myapp.TestParsing.test_colors failed: java.lang.NoSuchFieldError: Unknown, took 0.003 sec [error] at myapp.data$package$.actionDates(data.scala:139) [error] at myapp.TestParsing.test_colors(TestParsing.scala:66) [error] ...
If I move the definition of testData into the main project, vs the test itself, everything runs fine. Hence, no runtime error.
If I define Unknown as
case Unknown(dummy: Int = -1)
and useColor.Unknown()
everywhere, everything runs fine. Usingcase Unknown()
does not work.I have seen this error before. But the consumer was in the same main application vs the test module so I do not think this is a test framework issue.
dotty 0.18
The text was updated successfully, but these errors were encountered: