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

Incorrectly added BoxedUnit.UNIT to a no-parameter constructor call

    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
    • Labels:
      None

      Description

      I have this piece of code

      trait Bound

      { private val support = new PropertyChangeSupport() def firePropertyChange(name:String, oldVal:Object, newVal:Object) = support.firePropertyChange(name, oldVal, newVal) }

      I realized that I used a constructor which is NOT present in the java class. How is that possible ? A decompile yielded:

      public static void $init$(Bound $this)

      { $this.scala$test$Bound$_setter_$scala$test$Bound$$support_$eq(new PropertyChangeSupport(BoxedUnit.UNIT)); }

      So it seems the compiler tried to match the Object constructor with a default unit. Is this the proper behavior ?
      How can a programmer know that this substitution is happening ?

        Activity

        Hide
        Daniel Cardin added a comment - - edited

        It's not you I'm trying to convince. I am appealing to the higher authorities

        Show
        Daniel Cardin added a comment - - edited It's not you I'm trying to convince. I am appealing to the higher authorities
        Hide
        Paul Phillips added a comment -

        Most likely I'm your whole audience for these comments.

        Show
        Paul Phillips added a comment - Most likely I'm your whole audience for these comments.
        Hide
        Commit Message Bot added a comment -

        (extempore in r25410) Added two new compiler options:

        -Ywarn-adapted-args // also included in -Xlint
        -Yno-adapted-args

        The former warns when a () is inserted or an argument list is implicitly
        tupled. The latter errors under the same conditions. Using these options
        I found several bugs in the distribution which would otherwise be nearly
        impossible to spot. These bugs were innocuous (I think) but similar bugs
        could easily be (and have been) otherwise.

        Certain particularly threatening scenarios are at minimum warned about
        regardless of options given. Closes SI-4851, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25410 ) Added two new compiler options: -Ywarn-adapted-args // also included in -Xlint -Yno-adapted-args The former warns when a () is inserted or an argument list is implicitly tupled. The latter errors under the same conditions. Using these options I found several bugs in the distribution which would otherwise be nearly impossible to spot. These bugs were innocuous (I think) but similar bugs could easily be (and have been) otherwise. Certain particularly threatening scenarios are at minimum warned about regardless of options given. Closes SI-4851 , no review.
        Hide
        Paul Phillips added a comment -

        OK, that's the best I can do for now. Give -Xlint a try.

        Show
        Paul Phillips added a comment - OK, that's the best I can do for now. Give -Xlint a try.
        Hide
        Daniel Cardin added a comment -

        Thanks ! I'll try with -Xlint and try to get it added to the IDE plugin.

        Show
        Daniel Cardin added a comment - Thanks ! I'll try with -Xlint and try to get it added to the IDE plugin.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Daniel Cardin
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development