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

Type-checker crashes with StackOverflowError due to illegal cyclic type dependency

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.9.2
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None
    • Environment:

      Tested with Scala 2.9.1-final and 2.10.0.r25850-b20111019023417 on Windows

      Description

      This one-liner

      class T { def f[C[X] <: C[X]](l: C[_]) = l.x }
      

      makes scalac crash with a StackOverflowError

      error: java.lang.StackOverflowError
      	at scala.reflect.internal.Symbols$Symbol.isDeferred(Symbols.scala:45)
      	at scala.reflect.internal.Symbols$TypeSymbol.isAliasType(Symbols.scala:2088)
      	at scala.reflect.internal.Types$TypeRef.thisInfo(Types.scala:1769)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
      	at scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1041)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
      	at scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1041)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
      	at scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1041)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
      	at scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1041)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
      	at scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1041)
      	at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:1987)
          ...
      

        Activity

        Hide
        Commit Message Bot added a comment -

        (extempore in r25852) Cycle defense.

        Notice when a typeref's info creates an obvious cycle, so we can see an
        error instead of a stack overflow. Closes SI-5093, review by moors.

        Show
        Commit Message Bot added a comment - (extempore in r25852 ) Cycle defense. Notice when a typeref's info creates an obvious cycle, so we can see an error instead of a stack overflow. Closes SI-5093 , review by moors.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Stefan Zeiger
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development