code |
object P extends Application {
def f = new T { val state = State.A }
private object State extends Enumeration {
val A, B = Value
}
f
}
trait T {
}
/*
Using
private object State extends Enumeration {
we experience a runtime error:-
scalac -version
Scala compiler 2.3.3 -- (c) 2002-2007 LAMP/EPFL
scalac P.scala
scala P
java.lang.NoClassDefFoundError: P$P$$State$
at P$$anon$0.<init>(P.scala:4)
at P$.f(P.scala:4)
at P$.<init>(P.scala:10)
at P$.<clinit>(P.scala)
at P.main(P.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:76)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:107)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Using
object State extends Enumeration {
or
private[P] object State extends Enumeration {
we have successful execution.
*/
|