Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Jan 6, 2013 · 6 comments
Closed

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

scabug opened this issue Jan 6, 2013 · 6 comments
Milestone

Comments

@scabug
Copy link

scabug commented Jan 6, 2013

% 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
@scabug
Copy link
Author

scabug commented Jan 6, 2013

Imported From: https://issues.scala-lang.org/browse/SI-6923?orig=1
Reporter: @retronym
Assignee: @puffnfresh
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Jan 7, 2013

@puffnfresh said:
Pull request submitted: scala/scala#1854

@scabug scabug closed this as completed Jan 17, 2013
@scabug
Copy link
Author

scabug commented Mar 7, 2013

@SethTisue said:
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?

@scabug
Copy link
Author

scabug commented Mar 7, 2013

@paulp said:
== 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 ==.

@scabug
Copy link
Author

scabug commented Mar 14, 2013

@SethTisue said:
my sick love for -Xlint -Xfatal-warnings will be my undoing.

@scabug
Copy link
Author

scabug commented Mar 14, 2013

@paulp said:
scala/scala#2239 may put you to the test sooner than you think.

@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the 2.10.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant