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

Weird behavior with default arguments on traits when using FSC


    • Type: Bug
    • Status: CLOSED
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.9.2
    • Fix Version/s: Scala 2.10.0-M3, Scala 2.10.0
    • Component/s: Compiler (Misc)
    • Environment:

      Windows XP x64 SP2; JDK 1.6.0_21; IntelliJ IDEA 10.5.2; Scala Plugin for IntelliJ 0.4.1491


      Okay, this is a weird one. I suspect it's a bug against FSC, but honestly it could be the IntelliJ Scala plugin's fault; I just don't know.

      In one file, in src:

      package compilerbug
      trait SadTrait {
        def buggyMethod(argWithDefault: String = "default") {
          for (i <- 0 to 1) {
            val _ = argWithDefault
      object SadObject extends SadTrait

      In another file, in test:

      package compilerbug
      class TestClass {
        def repro() {

      With FSC disabled, this compiles fine. With FSC on, this complains:

      error: not enough arguments for method buggyMethod: (argWithDefault$1: String)Unit

      This appears to be a minimal repro to me; the problem goes away if:

      • TestClass lives in src as well
      • argWithDefault is not used in the for loop
      • the outside of the for loop is commented out leaving a bare val _ = argWithDefault
      • Inside buggyMethod, I let val argAlias = argWithDefault, and then use argAlias in the for loop
      • buggyMethod is defined directly on SadObject rather than in SadTrait

      Fortunately, the fourth bullet point is a pretty general workaround for this problem, so I'm not blocked on it... but weird, right?


          Issue Links



              • Assignee:
                retronym Jason Zaugg
                ryan.hendrickson_bwater Ryan Hendrickson
              • Votes:
                7 Vote for this issue
                10 Start watching this issue


                • Created: