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

Types$$TypeRef Types$$SubType stack overflow


    • Type: Bug
    • Status: CLOSED
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.1
    • Component/s: Type Checker
    • Labels:
    • Environment:

      stack overflow type parameter inference


      == Code ==

      // providing the type parameter in the recursive call to all4Impl
      // avoids the problem
      // covariant linked list
      abstract class M { 
        self =>
          type T
          final type selfType = M {type T <: self.T}
          type actualSelfType >: self.type <: selfType
          def next: selfType
          // I don't understand why this doesn't compile, but that's a separate matter
          // error: method all2 cannot be accessed in M.this.selfType
          // because its instance type => Stream[M{type T <: M.this.selfType#T}]
          // contains a malformed type: M.this.selfType#T
          // def all2: Stream[M {type T <: self.T}] = Stream.cons(self: actualSelfType, next.all2)
          // compiles successfully
          // def all3: Stream[M {type T <: self.T}] = all3Impl(self: actualSelfType)
          // private def all3Impl(first: M {type T <: self.T}): Stream[M {type T <: self.T}] = Stream.cons(first, all3Impl(first.next))
          def all4: Stream[M {type T <: self.T}] = Unrelated.all4Impl[T](self: actualSelfType)
      object Unrelated {
          def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl(first.next))
          // compiles successfully
          // def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl[U](first.next))

      == What happened ==

      Exception in thread "main" java.lang.StackOverflowError
      	at scala.tools.nsc.symtab.Symbols$$ClassSymbol.name(Symbols.scala:1335)
      	at scala.tools.nsc.symtab.Symbols$$Symbol.rawInfo(Symbols.scala:502)
      	at scala.tools.nsc.symtab.Symbols$$Symbol.info(Symbols.scala:473)
      	at scala.tools.nsc.symtab.Symbols$$Symbol.closureLength$$0(Symbols.scala:624)
      	at scala.tools.nsc.symtab.Symbols$$Symbol.isLess(Symbols.scala:627)
      	at scala.tools.nsc.symtab.Types$$Type.closurePos(Types.scala:528)
      	at scala.tools.nsc.symtab.Symbols$$Symbol.isNonBottomSubClass(Symbols.scala:643)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.toPrefix$$0(Types.scala:2229)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2236)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2210)
      	at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2087)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2281)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2210)
      	at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2100)
      	at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2281)
      	at scala.tools.nsc.symtab.Types$$Type.asSeenFrom(Types.scala:367)
      	at scala.tools.nsc.symtab.Types$$Type.memberInfo(Types.scala:374)
      	at scala.tools.nsc.symtab.Types$$TypeRef.relativeInfo(Types.scala:1283)
      	at scala.tools.nsc.symtab.Types$$TypeRef.baseType(Types.scala:1396)
      	at scala.tools.nsc.symtab.Types$$SubType.baseType(Types.scala:710)

      == What expected ==

      successful compilation




            • Assignee:
              moors Adriaan Moors
              michelou Stephane Micheloud
              Paul Phillips, Simon Ochsenreither
            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created: