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

closure in locally defined trait crashes in MixinTransformer

    Details

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

      Description

      [Update: I hit this again and here is how you can hit it too.]

        def f1(t: String) = {
          trait T {
            def xs = Nil map (_ => t)
          }
          ()
        }
      
      Exception in thread "main" java.lang.AssertionError: assertion failed
      	at scala.Predef$$.assert(Predef.scala:79)
      	at scala.tools.nsc.transform.Mixin$$MixinTransformer.scala$$tools$$nsc$$transform$$Mixin$$MixinTransformer$$$$postTransform(Mixin.scala:1031)
      	at scala.tools.nsc.transform.Mixin$$MixinTransformer$$$$anonfun$$16.apply(Mixin.scala:1057)
      	at scala.tools.nsc.transform.Mixin$$MixinTransformer$$$$anonfun$$16.apply(Mixin.scala:1057)
      	at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:104)
      	at scala.tools.nsc.transform.Mixin$$MixinTransformer.transform(Mixin.scala:1057)
      

      [Original report follows]
      I haven't reduced this yet, but it's easy to reproduce: take current trunk as (r20482 right now) and one line in IndexedSeqViewLike.scala.

        trait Filtered extends Transformed[A] with super.Filtered {
          // add this override
          override def foreach[U](f: A => U) = super[Transformed].foreach(f)
        }
      

      And scalac will crash with:

      [scalacfork] Exception in thread "main" java.lang.AssertionError: assertion failed
      [scalacfork] 	at scala.Predef$$.assert(Predef.scala:89)
      [scalacfork] 	at scala.tools.nsc.transform.Mixin$$MixinTransformer.scala$$tools$$nsc$$transform$$Mixin$$MixinTransformer$$$$postTransform(Mixin.scala:1012)
      [scalacfork] 	at scala.tools.nsc.transform.Mixin$$MixinTransformer$$$$anonfun$$16.apply(Mixin.scala:1060)
      [scalacfork] 	at scala.tools.nsc.transform.Mixin$$MixinTransformer$$$$anonfun$$16.apply(Mixin.scala:1060)
      [scalacfork] 	at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:99)
      [...]
      

        Activity

        Hide
        Paul Phillips added a comment -

        Oh, and hopefully I don't have to say this, but please don't interpret the fact that I reverted the lines in the above example as in any way invalidating this bug. It's the opposite, this bug may have stood between me and a solution to SI-2876. Not for sure, but it's irrelevant because this bug is real and reproducible: but you might need to check out r20482 to easily reproduce it.

        Show
        Paul Phillips added a comment - Oh, and hopefully I don't have to say this, but please don't interpret the fact that I reverted the lines in the above example as in any way invalidating this bug. It's the opposite, this bug may have stood between me and a solution to SI-2876 . Not for sure, but it's irrelevant because this bug is real and reproducible: but you might need to check out r20482 to easily reproduce it.
        Hide
        Paul Phillips added a comment -

        I just hit this one again. I keep finding my own opened tickets when searching to make sure I'm not opening a duplicate. That is the universe's way of telling me "fix it yourself!"

        This time I was able to create a small reproduction, which I am putting in the description.

        Show
        Paul Phillips added a comment - I just hit this one again. I keep finding my own opened tickets when searching to make sure I'm not opening a duplicate. That is the universe's way of telling me "fix it yourself!" This time I was able to create a small reproduction, which I am putting in the description.
        Hide
        Martin Odersky added a comment -

        (In r21420) Interrupted attempt to fix SI-2897. I am committing what I have because the refactorings improve things a little bit. To fix the ticket a frightening lot more has to be done.

        Show
        Martin Odersky added a comment - (In r21420) Interrupted attempt to fix SI-2897 . I am committing what I have because the refactorings improve things a little bit. To fix the ticket a frightening lot more has to be done.
        Hide
        Paul Phillips added a comment -

        Closing as a duplicate of SI-6231.

        Show
        Paul Phillips added a comment - Closing as a duplicate of SI-6231 .

          People

          • Assignee:
            Martin Odersky
            Reporter:
            Paul Phillips
            TracCC:
            Ismael Juma, Paul Phillips, Seth Tisue
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development