Scala Programming Language
  1. Scala Programming Language
  2. SI-5071

traits with self-types crash upon specialization

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      trait Foo[@specialized A, Repr] {
        self: Repr =>
      }
      trait Bar[A] extends Foo[A, Object] { }
      
      error: scala.reflect.internal.Types$TypeError: illegal inheritance;
       self-type Foo$mcV$sp[Repr] does not conform to Foo[Unit,Repr]'s selftype Foo[Unit,Repr] with Repr
      	at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:283)
      	at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:207)
      	at scala.tools.nsc.typechecker.Typers$Typer.validateParentClass$1(Typers.scala:1293)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$validateParentClasses$1.apply(Typers.scala:1304)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$validateParentClasses$1.apply(Typers.scala:1304)
      	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
      

      I tried fixing this by setting typeOfThis on the specialized classes to include the self type of the original class, but I didn't get anywhere. Suppressing the conformance check in Typers only moves the crash further downfield.

      This issue prevents the specialization of e.g. LinearSeqOptimized.

        Activity

        Hide
        Paul Phillips added a comment -

        I take that back, I figured it out.

        Show
        Paul Phillips added a comment - I take that back, I figured it out.
        Hide
        Commit Message Bot added a comment -

        (extempore in r25823) Propagate self-type to specialized subclasses.

        Closes SI-5071, review by prokopec.

        Show
        Commit Message Bot added a comment - (extempore in r25823 ) Propagate self-type to specialized subclasses. Closes SI-5071 , review by prokopec.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development