I'm am trying to use a case class that has one attribute reference another case class. But there are certain conditions where I construct the object that I get strange type errors.
So something like this works fine.
case class Foo(a:Int)
case class Bar(b:Foo, c:Foo)
val t = Bar(Foo(1),Foo(2))
//t: Bar = Bar(Foo(1),Foo(2))
When I nest it into an object, there doesn't seem to be any problem
object w {
case class Foo(a:Int)
case class Bar(b:Foo, c:Foo)
}
I can even create an object
val t = w.Bar(w.Foo(1),w.Foo(2))
However, when I try to construct the object from the previously defined Foo, it gives me a crazy type error.
val f = w.Foo(1)
w.Bar(f,f)
// error: type mismatch;
// found : w.Foo
// required: w.Foo
// w.Bar(f,f)
Any ideas? Scala 2.10.5