Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-4365

type parameterization unstable based on file compilation order

    Details

      Description

      Extracted from SI-4305, where adriaan has some more info.

      // 1.scala
      trait Derived[+SA, +This <: Derived[SA, This]] extends Base[SA, This] {
        trait Reversed extends super.Reversed with super.Transformed[SA]
        protected override def newReversed: super.Transformed[SA] = new Reversed { } 
      }
       
      // 2.scala
      trait Base[+A, +This <: Base[A, This]] {
        trait Transformed[+B] {
          override def toString: String = error("")
        }
       
        trait Reversed extends Transformed[A] {
          private def x: Unit = {x: A => error("") }
        }
       
        protected def newReversed: Transformed[A] = new Reversed { }
      }  
      

      % scalac29 1.scala 2.scala 
      error: java.lang.Error: A in trait Base cannot be instantiated from [+A,+This <: Base[A,This]]Base[A,This]
      	at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:35)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.throwError$$1(Types.scala:3389)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.instParam$$1(Types.scala:3392)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.toInstance$$1(Types.scala:3403)
       
      % scalac29 2.scala 1.scala
      %
      

      Assigning to myself, but don't infer that I know anything about how to fix it, I'm just diving in front of the bullet.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                extempore Paul Phillips
                Reporter:
                extempore Paul Phillips
                TracCC:
                Johannes Rudolph, Paul Phillips
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: