bug icon indicating copy to clipboard operation
bug copied to clipboard

Illegal duplicate inheritance error not issued for ProductN (and other potential case class parents)

Open scabug opened this issue 10 years ago • 5 comments

I noticed this loophole when perusing fixDuplicateSyntheticParents in Typers.

scala> trait T[A]
defined trait T

scala> abstract class C(i: Int) extends T[Int] with T[String]
<console>:8: error: illegal inheritance;
 self-type C does not conform to T[Int]'s selftype T[Int]
       abstract class C(i: Int) extends T[Int] with T[String]
                                        ^
<console>:8: error: illegal inheritance;
 self-type C does not conform to T[String]'s selftype T[String]
       abstract class C(i: Int) extends T[Int] with T[String]
                                                    ^

scala> abstract class C(i: Int) extends Product1[Int] with Product1[String]
defined class C

We should easily be able to:

  • limit that code to case classes
  • remove ProductN from the list of potentially synthetic parents (as it is no longer even experimentally a case class parent)

scabug avatar Feb 26 '15 02:02 scabug

Imported From: https://issues.scala-lang.org/browse/SI-9187?orig=1 Reporter: @retronym Affected Versions: 2.11.5

scabug avatar Feb 26 '15 02:02 scabug

Is it still reproducible on 2.13.8?

SethTisue avatar Feb 24 '22 17:02 SethTisue

Is it still reproducible on 2.13.8?

Yes it is

joroKr21 avatar Feb 25 '22 07:02 joroKr21

@dwijnand you've been in this area on the Scala 3 side lately. is there anything we should crosslink?

SethTisue avatar Mar 14 '22 21:03 SethTisue

No, this just looks like a bug in the Scala 2 check.

dwijnand avatar Mar 14 '22 21:03 dwijnand