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

AnyRef specialization in class plus method causes type mismatch compiler crash

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0, Scala 2.9.1
    • Fix Version/s: Scala 2.10.0
    • Component/s: Specialization
    • Labels:
    • Environment:

      Description

      This crashes the compiler.

      package crasher {
        class Z[@specialized A, @specialized(AnyRef) B](var a: A, var b: B) { }
        object O {
          def apply[@specialized A, @specialized(AnyRef) B](a0: A, b0: B) = 
            new Z(a0,b0)
        }
      }
      

      For the crash to occur, you need at least two specialized types, at least one has to be AnyRef, and there have to be at least two specialized types for at least one of the entries.

      The compiler complains:

      error: scala.tools.nsc.symtab.Types$TypeError: type mismatch;
       found   : B$sp(in method apply$mVTc$sp)
       required: B$sp(in class Z$mcVT$sp)
      	at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:291)
      	at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:205)
      	at scala.tools.nsc.typechecker.Infer$Inferencer.typeError(Infer.scala:215)
      	at scala.tools.nsc.typechecker.Infer$Inferencer.typeErrorTree(Infer.scala:230)
      	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:929)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4219)
              ...
      

        Activity

        Hide
        Paul Phillips added a comment -

        bb23d766bc

        Show
        Paul Phillips added a comment - bb23d766bc
        Hide
        Paul Phillips added a comment -

        Reopening, I didn't really fix this, it just stopped happening when I broke something else, and unbreaking that put this back the way it was.

        Show
        Paul Phillips added a comment - Reopening, I didn't really fix this, it just stopped happening when I broke something else, and unbreaking that put this back the way it was.
        Hide
        Paul Phillips added a comment -

        Fixed along with SI-5500, test in 87e369ef46 .

        Show
        Paul Phillips added a comment - Fixed along with SI-5500 , test in 87e369ef46 .
        Hide
        Stefan Zeiger added a comment -
        Show
        Stefan Zeiger added a comment - Related Zendesk ticket: http://support.typesafe.com/tickets/1642

          People

          • Assignee:
            Aleksandar Prokopec
            Reporter:
            Rex Kerr
          • Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development