Skip to content

Instantly share code, notes, and snippets.

@ueshin
Created October 1, 2012 15:00
Show Gist options
  • Save ueshin/3812299 to your computer and use it in GitHub Desktop.
Save ueshin/3812299 to your computer and use it in GitHub Desktop.
ValueClassesのバグ?
package object example {
implicit class Foo(val foo: String) extends AnyVal {
def hello = println("hello")
}
}
package example
package object sub {
implicit class Baa(val baa: String) extends AnyVal {
def world = println("world")
}
}
package example
package sub
object Test extends App {
"1".hello
"2".world
}
> run
[info] Compiling 1 Scala source to /Users/ueshin/workspace/valueclasses/target/scala-2.10.0-M7/classes...
[info] Running example.sub.Test
[error] (run-main) java.lang.ClassCastException: example.sub.package$ cannot be cast to example.package$
java.lang.ClassCastException: example.sub.package$ cannot be cast to example.package$
at example.sub.Test$delayedInit$body.apply(test.scala:6)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:61)
at scala.App$$anonfun$main$1.apply(App.scala:61)
at scala.collection.immutable.List.foreach(List.scala:309)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
at scala.App$class.main(App.scala:61)
at example.sub.Test$.main(test.scala:4)
at example.sub.Test.main(test.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[error] {file:/Users/ueshin/workspace/valueclasses/}default-5d25e6/compile:run: Nonzero exit code: 1
[error] Total time: 1 s, completed 2012/10/01 23:50:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment