« Return to Thread: [scala] Bounds on abstract types

[scala] Re: [scala-user] Bounds on abstract types

by Chris Twiner :: Rate this Message:

Reply to Author | View in Thread

On Fri, Jun 19, 2009 at 6:15 PM, Vladimir
Reshetnikov<v.reshetnikov@...> wrote:

> Hi,
>
> Consider this code:
>
> ////////////////////////////////////////
> trait A {
>  type T <: this.type with C
> }
>
> trait B extends A {
>  type T <: this.type with C
> }
>
> trait C extends B {
>  type T <: this.type with C
> }
> ////////////////////////////////////////
>
> Scala compiler rejects it:
>
> <console>:11: error: overriding type T in trait B with bounds >:
> Nothing <: C.this.type with C;
>  type T has incompatible type
>         type T <: this.type with C
>              ^
>
> But the following is accepted:
>
> ////////////////////////////////////////
> trait A {
>  type T <: this.type with C
> }
>
> trait B extends A {
>  type T <: this.type with C
> }
>
> trait C extends B {
> }
> ////////////////////////////////////////
>
> Can anybody explain, why?
>
> Thanks,
> Vladimir
>

With 2.8 trunk (at least via the nightly eclipse build) this error
doesn't occur.  Are you using 2.7.x for testing this?

 « Return to Thread: [scala] Bounds on abstract types