Created
February 12, 2013 14:00
-
-
Save holograph/4770065 to your computer and use it in GitHub Desktop.
Reduced repro case for Scala 2.10 compiler issue, issue link to be to added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Reproduction scenario for Scala 2.10 compiler issue. | |
To compile: scalac Test.scala | |
To execute: | |
wanamingo:tmp tomer$ scala com.tomergabel.examples.Test | |
java.lang.ClassFormatError: Duplicate method name&signature in class file com/tomergabel/examples/Derived$$anonfun$defect$1 | |
at java.lang.ClassLoader.defineClass1(Native Method) | |
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) | |
at java.lang.ClassLoader.defineClass(ClassLoader.java:615) | |
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) | |
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) | |
at java.net.URLClassLoader.access$000(URLClassLoader.java:58) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:197) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) | |
at com.tomergabel.examples.Derived$class.defect(Test.scala:11) | |
at com.tomergabel.examples.Test$.defect(Test.scala:14) | |
at com.tomergabel.examples.Test$delayedInit$body.apply(Test.scala:15) | |
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:71) | |
at scala.App$$anonfun$main$1.apply(App.scala:71) | |
at scala.collection.immutable.List.foreach(List.scala:309) | |
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32) | |
at scala.App$class.main(App.scala:71) | |
at com.tomergabel.examples.Test$.main(Test.scala:14) | |
at com.tomergabel.examples.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) | |
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71) | |
at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31) | |
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139) | |
at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71) | |
at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139) | |
at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28) | |
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45) | |
at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35) | |
at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45) | |
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74) | |
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96) | |
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105) | |
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala) | |
Note scalap output for problematic class: | |
wanamingo:tmp tomer$ scalap -cp . 'com.tomergabel.examples.Derived$$anonfun$defect$1' | |
package com.tomergabel.examples; | |
final class Derived$$anonfun$defect$1 extends scala.runtime.AbstractPartialFunction with scala.Serializable { | |
def this(com.tomergabel.examples.Derived): scala.Unit; | |
def applyOrElse(scala.Any, scala.Function1): scala.Any; | |
def isDefinedAt(scala.Any): scala.Boolean; | |
def isDefinedAt(com.tomergabel.examples.Container): scala.Boolean; | |
def applyOrElse(scala.Any, scala.Function1): scala.Any; | |
} | |
object Derived$$anonfun$defect$1 { | |
final val serialVersionUID: scala.Long; | |
} | |
Work around by qualifiying the return type of Derived.defect: | |
protected def defect: PartialFunction[ Container, String ] = { case c: Container => c.v.toString } | |
*/ | |
package com.tomergabel.examples | |
case class Container( v: String ) | |
trait Base[ T <: AnyRef ] { | |
type UserType = T | |
protected def defect: PartialFunction[ UserType, String ] | |
} | |
trait Derived extends Base[ Container ] { | |
protected def defect = { case c: Container => c.v.toString } | |
} | |
object Test extends Derived with App { | |
println( defect( Container( "8" ) ) ) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment