« Return to Thread: [scala] Cryptic error for a type definition within block

Re: [scala] Cryptic error for a type definition within block

by James Iry-2 :: Rate this Message:

Reply to Author | View in Thread

related to http://lampsvn.epfl.ch/trac/scala/ticket/1201

On Thu, Jun 18, 2009 at 6:32 AM, Vladimir Reshetnikov <v.reshetnikov@...> wrote:
Hi,

I try to compile this:

////////////////////////
object A {
 def f = {
   object B
   B
 }
 val x = f
}
////////////////////////

The result is a rather cryptic error:

a.scala:6: error: type mismatch;
 found   : B.type(in object A) where type B.type(in object A) <: B
with Singleton
 required: B.type(in value x) forSome { type B.type(in value x) <: B
with Singleton; type B <: java.lang.Object with ScalaObject }
 val x = f
     ^

Interesting that it appears not in the definition of f, but in the
definition of x (and disappears if the line val x = f is removed).
Can anybody explain this in more detail?

Thanks,
Vladimir

 « Return to Thread: [scala] Cryptic error for a type definition within block