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

Compiler Crash - trait method with Symbol parameter and default value

    Details

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

      java 1.6.0_24 on Mac OS 10.6.7. sbt 0.7.7 and 0.10.1

      Description

      The following source

      trait Test1 {
       def m1(sym: Symbol = 'TestSym)
      }
      

      crashes the compiler:

      uncaught exception during compilation: java.util.NoSuchElementException
      error: java.util.NoSuchElementException
      	at scala.collection.LinearSeqOptimized$class.last(LinearSeqOptimized.scala:135)
      	at scala.collection.immutable.List.last(List.scala:77)
      	at scala.tools.nsc.backend.icode.Members$IMethod.lastBlock(Members.scala:159)
      	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.addStaticInit(GenJVM.scala:995)
      	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$1.apply(GenJVM.scala:445)
      	at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$1.apply(GenJVM.scala:445)
      [...]
      

        Activity

        Hide
        Paul Phillips added a comment -

        Feels like default parameters.

        Show
        Paul Phillips added a comment - Feels like default parameters.
        Hide
        Remo Lemma added a comment - - edited

        I investigated this bug, and it seems that there was a problem on how the compiler treats default parameters in abstract methods of traits.
        This patch should solve the issue. I tested it with different test cases and of course checked that the test suite still finishes with no problems.

        Show
        Remo Lemma added a comment - - edited I investigated this bug, and it seems that there was a problem on how the compiler treats default parameters in abstract methods of traits. This patch should solve the issue. I tested it with different test cases and of course checked that the test suite still finishes with no problems.
        Hide
        Lukas Rytz added a comment - - edited

        fixed in https://github.com/scala/scala/commit/57967c9d1e93aa3a4d26fc02f13172f4622ed9e3

        The crash is in CleanUp: It generates a static field & constructor in the interface class (that's wrong) because the "scala.Symbol.apply(...)" code remains in the interface as a default argument. Fixed by removing all default arguments from parameter ValDefs in UnCurry.

        Show
        Lukas Rytz added a comment - - edited fixed in https://github.com/scala/scala/commit/57967c9d1e93aa3a4d26fc02f13172f4622ed9e3 The crash is in CleanUp: It generates a static field & constructor in the interface class (that's wrong) because the "scala.Symbol.apply(...)" code remains in the interface as a default argument. Fixed by removing all default arguments from parameter ValDefs in UnCurry.

          People

          • Assignee:
            Lukas Rytz
            Reporter:
            John Bruce
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development