2.10 regression: “error: illegal inheritance; self-type does not conform to ...”

166 views
Skip to first unread message

Simon Ochsenreither

unread,
Aug 8, 2012, 5:35:33 PM8/8/12
to scala-i...@googlegroups.com
Hi everyone,

I was pretty sure that there was already a bug filed, but even after searching for it multiple times, I can't find it.

The following (minimized) code compiled with 2.9, but fails to compile with 2.10:

  trait TFn1[I] { type In = I }
  trait >>[F1 <: TFn1[_], F2 <: TFn1[_]] extends TFn1[F1#In]

<console>:8: error: illegal inheritance;
 self-type >>[F1,F2] does not conform to TFn1[_$1]'s selftype TFn1[_$1]
         trait >>[F1 <: TFn1[_], F2 <: TFn1[_]] extends TFn1[F1#In]
                                                        ^
Does someone maybe remember the ticket number or should I file a new one?

Thanks a lot!

Simon

Paul Phillips

unread,
Aug 9, 2012, 12:41:16 AM8/9/12
to scala-i...@googlegroups.com


On Wed, Aug 8, 2012 at 2:35 PM, Simon Ochsenreither <simon.och...@gmail.com> wrote:
Does someone maybe remember the ticket number or should I file a new one?

It does have that feel of a bunch of other tickets, and I can't find it either.  I'd say open it.

martin odersky

unread,
Aug 9, 2012, 3:53:28 AM8/9/12
to scala-i...@googlegroups.com
I wonder whether it has anything to do with the recent fix to 


?

Is there a project that uses this code?

  - Martin
--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967

Paul Phillips

unread,
Aug 9, 2012, 6:05:44 AM8/9/12
to scala-i...@googlegroups.com


On Thu, Aug 9, 2012 at 12:53 AM, martin odersky <martin....@epfl.ch> wrote:
I wonder whether it has anything to do with the recent fix to 


No, the test case fails all the way back to M1, so it regressed in January or before.

martin odersky

unread,
Aug 9, 2012, 6:07:17 AM8/9/12
to scala-i...@googlegroups.com
OK. Can we do a bisect to find out what it was?

 - Martin

Simon Ochsenreither

unread,
Aug 9, 2012, 6:20:19 AM8/9/12
to scala-i...@googlegroups.com
Metascala uses it, and therefore also scalax-units.

Ticket: https://issues.scala-lang.org/browse/SI-6211

Paul Phillips

unread,
Aug 9, 2012, 6:24:25 AM8/9/12
to scala-i...@googlegroups.com


On Thu, Aug 9, 2012 at 3:07 AM, martin odersky <martin....@epfl.ch> wrote:
OK. Can we do a bisect to find out what it was?

We lucked out; my builds stop last november but it was slightly before that.  It's this:


martin odersky

unread,
Aug 9, 2012, 6:43:57 AM8/9/12
to scala-i...@googlegroups.com
Thanks! That's good to know. I think there's not much we can do here for the moment. The patch is necessary because it fixes an unsoundness problem.  I am not quite clear what the breaking code does. It looks like it can be compiled if we can get rid of unrestricted existentials. But this will be definitely post 2.10.

Cheers

 - Martin


Paul Phillips

unread,
Aug 9, 2012, 1:41:14 PM8/9/12
to scala-i...@googlegroups.com


On Thu, Aug 9, 2012 at 3:43 AM, martin odersky <martin....@epfl.ch> wrote:
Thanks! That's good to know. I think there's not much we can do here for the moment. The patch is necessary because it fixes an unsoundness problem.  I am not quite clear what the breaking code does. It looks like it can be compiled if we can get rid of unrestricted existentials. But this will be definitely post 2.10.

In the meantime, these variations still compile:

// 1
trait TFn1[I] { type In <: I }
trait >>[F1 <: TFn1[_], F2 <: TFn1[_]] extends TFn1[F1#In]

// 2
trait TFn1[I] { type In0 <: I ; type In = In0 }
trait >>[F1 <: TFn1[_], F2 <: TFn1[_]] extends TFn1[F1#In0]

Dave

unread,
Aug 9, 2012, 2:20:09 PM8/9/12
to scala-i...@googlegroups.com

It looks like the type inference problem with type projections in this thread:


https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-language/ww_hapKyL2w%5B1-25%5D


and Paul's solution still works


trait TFn1[I] { type In = I }
trait >>[S,F1 <: TFn1[_]{type In = S}, F2 <: TFn1[_]] extends TFn1[S]

Op donderdag 9 augustus 2012 19:41:14 UTC+2 schreef Paul Phillips het volgende:

Simon Ochsenreither

unread,
Aug 9, 2012, 2:31:56 PM8/9/12
to scala-i...@googlegroups.com
Hi Paul,

great idea! Although this makes the minimized example compile, it fails with the original:

  trait TFn1B {
    type In
    type Out
    type Apply[T <: In] <: Out
  }

  trait TFn1[I, O] extends TFn1B {
    type In <: I
    type Out <: O
  }

  type ->[Arg, F <: TFn1[Arg, _]] = F#Apply[Arg]

  trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
    type Apply[T] = F2#Apply[F1#Apply[T]]
  }

Errors:

<console>:18: error: type arguments [Arg] do not conform to type Apply's type parameter bounds [T <: TFn1B.this.In]
         type ->[Arg, F <: TFn1[Arg, _]] = F#Apply[Arg]
                                             ^
<console>:21: error: overriding type Apply in trait TFn1B with bounds[T <: >>.this.In] <: >>.this.Out;
 type Apply has incompatible type
           type Apply[T] = F2#Apply[F1#Apply[T]]
                ^
<console>:21: error: type arguments [F1#Apply[T]] do not conform to type Apply's type parameter bounds [T <: TFn1B.this.In]
           type Apply[T] = F2#Apply[F1#Apply[T]]
                              ^

What do you think?

Bye,

Simon

Paul Phillips

unread,
Aug 9, 2012, 3:23:12 PM8/9/12
to scala-i...@googlegroups.com


On Thu, Aug 9, 2012 at 11:31 AM, Simon Ochsenreither <simon.och...@gmail.com> wrote:
What do you think?

Well, it's not for the faint of heart.  It looks to me like the former version was unsound, so some of these changes are legitimate.  The fact that I have to "override type" should be a bug.  But at least it works (I mean, compiles.)

object Functions {
  trait TFn1B {
    type In
    type Out
    type Apply[T <: In] <: Out
  }

  trait TFn1[I, O] extends TFn1B {
    type In >: I
    type Out <: O
  }

  type ->[Arg, F <: TFn1[Arg, _]] = F#Apply[Arg]

  trait >>[F1 <: TFn1[_, _ <: F2#In], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
    override type In = F1#In
    override type Out = F2#Out
    type Apply[T <: In] = F2#Apply[F1#Apply[T]]
  }
}

Reply all
Reply to author
Forward
0 new messages