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

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

by nikov :: Rate this Message:

Reply to Author | View in Thread

Thanks, James. This is exactly the same.

Vladimir

On 6/18/09, James Iry <jamesiry@...> wrote:

> 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