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

Compiler Crash - trait method with Symbol parameter and default value

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: None
    • Component/s: Compiler (Misc)
    • 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)
      [...]
      

        Attachments

          Activity

          Hide
          extempore Paul Phillips added a comment -

          Feels like default parameters.

          Show
          extempore Paul Phillips added a comment - Feels like default parameters.
          Hide
          coloss 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
          coloss 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
          rytz 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
          rytz 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:
              rytz Lukas Rytz
              Reporter:
              scimonkey John Bruce
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: