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

-Ywarn-adapted-args doesn't detect monomorphic call

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.1
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      % scala210 -Ywarn-adapted-args -Xfatal-warnings -e 'def foo(a: Any) = a; foo(1, 2)'
      # Warning expected here.
      
      % scala210 -Ywarn-adapted-args -Xfatal-warnings -e 'def foo[A](a: Any) = a; foo(1, 2)'
      /var/folders/xq/4pqxykpn5n56mngmch4p5xgw0000gn/T/scalacmd4298701803865603272.scala:1: error: Adapting argument list by creating a 2-tuple: this may not be what you want.
              signature: $anon.foo[A](a: Any): Any
        given arguments: 1, 2
       after adaptation: $anon.foo((1, 2): (Int, Int))
      def foo[A](a: Any) = a; foo(1, 2)
                                 ^
      one error found
      
      % scala210 -Yno-adapted-args  -e 'def foo[A](a: Any) = a; foo(1, 2)'
      /var/folders/xq/4pqxykpn5n56mngmch4p5xgw0000gn/T/scalacmd5030784570605432719.scala:1: warning: No automatic adaptation here: use explicit parentheses.
              signature: $anon.foo[A](a: Any): Any
        given arguments: 1, 2
       after adaptation: $anon.foo((1, 2): (Int, Int))
      def foo[A](a: Any) = a; foo(1, 2)
                                 ^
      /var/folders/xq/4pqxykpn5n56mngmch4p5xgw0000gn/T/scalacmd5030784570605432719.scala:1: error: too many arguments for method foo: (a: Any)Any
      def foo[A](a: Any) = a; foo(1, 2)
                                 ^
      one warning found
      one error found
      
      % scala210 -Yno-adapted-args  -e 'def foo(a: Any) = a; foo(1, 2)'
      /var/folders/xq/4pqxykpn5n56mngmch4p5xgw0000gn/T/scalacmd8192043649954446982.scala:1: error: too many arguments for method foo: (a: Any)Any
      def foo(a: Any) = a; foo(1, 2)
                              ^
      one error found
      

        Activity

        Hide
        Brian McKenna added a comment -
        Show
        Brian McKenna added a comment - Pull request submitted: https://github.com/scala/scala/pull/1854
        Hide
        Seth Tisue added a comment -

        In 2.10.0 even with -Ywarn-adapted-args we had:

        scala> (1, 2) == (1, 2)
        res0: Boolean = true
        

        but in 2.10.1-RC3 with -Ywarn-adapted-args we now get:

        scala> (1, 2) == (1, 2)
        <console>:8: warning: Adapting argument list by creating a 2-tuple: this may not be what you want.
                signature: Object.==(x$1: AnyRef): Boolean
          given arguments: 1, 2
         after adaptation: Object.==((1, 2): (Int, Int))
                      (1, 2) == (1, 2)
                             ^
        res0: Boolean = true
        

        I'm guessing the change is the result of this fix.

        Is there a drift towards making -Ywarn-adapted-args or -Yno-adapted-args the default? If so, this case might give us pause. Shouldn't comparing tuples with == be a perfectly fine thing to do?

        Show
        Seth Tisue added a comment - In 2.10.0 even with -Ywarn-adapted-args we had: scala> (1, 2) == (1, 2) res0: Boolean = true but in 2.10.1-RC3 with -Ywarn-adapted-args we now get: scala> (1, 2) == (1, 2) <console>:8: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. signature: Object.==(x$1: AnyRef): Boolean given arguments: 1, 2 after adaptation: Object.==((1, 2): (Int, Int)) (1, 2) == (1, 2) ^ res0: Boolean = true I'm guessing the change is the result of this fix. Is there a drift towards making -Ywarn-adapted-args or -Yno-adapted-args the default? If so, this case might give us pause. Shouldn't comparing tuples with == be a perfectly fine thing to do?
        Hide
        Paul Phillips added a comment -

        == is broken; can't fix a method which accepts Any. I don't know of any drift toward making this warning the default. If it were, I suppose I'd exclude ==.

        Show
        Paul Phillips added a comment - == is broken; can't fix a method which accepts Any. I don't know of any drift toward making this warning the default. If it were, I suppose I'd exclude ==.
        Hide
        Seth Tisue added a comment -

        my sick love for `-Xlint -Xfatal-warnings` will be my undoing.

        Show
        Seth Tisue added a comment - my sick love for `-Xlint -Xfatal-warnings` will be my undoing.
        Hide
        Paul Phillips added a comment -

        https://github.com/scala/scala/pull/2239 may put you to the test sooner than you think.

        Show
        Paul Phillips added a comment - https://github.com/scala/scala/pull/2239 may put you to the test sooner than you think.

          People

          • Assignee:
            Brian McKenna
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development