Created
September 19, 2010 23:32
-
-
Save fedesilva/587218 to your computer and use it in GitHub Desktop.
Redefining companion kabooms
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
package caseclasses | |
case class A() | |
//This compiles Just Fine | |
object A | |
class Z { | |
def run(fun: => Unit) = fun | |
} | |
class Y extends Z { | |
case class B() | |
object B //This compiles Just Fine | |
run { | |
case class C() | |
//object C | |
// | |
//If I redefine C I get: | |
//src/main/scala/caseclasses.scala:30: C is already defined as (compiler-generated) case class companion object C | |
//[error] object C | |
//[error] ^ | |
//[error] one error found | |
// | |
} | |
def method { | |
case class D() | |
//object D | |
// | |
//src/main/scala/caseclasses.scala:34: D is already defined as (compiler-generated) case class companion object D | |
//[error] object D | |
//[error] ^ | |
//[error] one error found | |
} | |
} | |
Yes, it is. https://issues.scala-lang.org/browse/SI-3772.
Cool thanks. Just voted on the bug.
The workaround iirc is to define the companion object first.
I tried this but I get other compiler errors. For now I'll move this out of my method.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hit the same issue. Is this in the Scala tracker?