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
incorrect "implicit numeric widening" warning when evaluating expression #8450
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8450?orig=1 |
@adriaanm said: |-- System.nanoTime.$minus(100L).foo : pt=Foo EXPRmode (site: method elapsed in $iw)
| |-- System.nanoTime.$minus(100L) EXPRmode-POLYmode-QUALmode (site: method elapsed in $iw)
| | |-- System.nanoTime.$minus BYVALmode-EXPRmode-FUNmode-POLYmode (silent: method elapsed in $iw)
| | | |-- System.nanoTime EXPRmode-POLYmode-QUALmode (silent: method elapsed in $iw)
| | | | |-- System EXPRmode-POLYmode-QUALmode (silent: method elapsed in $iw)
| | | | | \-> System.type
| | | | |-- ()Long EXPRmode (silent: method elapsed in $iw)
| | | | | \-> Long
| | | | [adapt] ()Long adapted to ()Long
| | | | \-> Long
| | | \-> (x: Double)Double <and> (x: Float)Float <and> (x: Long)Long <and> (x: Int)Long <and> (x: Char)Long <and> (x: Short)Long <and> (x: Byte)Long
| | |-- 100L BYVALmode-EXPRmode (silent: method elapsed in $iw)
| | | \-> Long(100L)
| | \-> Long
| |-- FooDouble BYVALmode-EXPRmode-FUNmode-POLYmode (silent: method elapsed in $iw) implicits disabled
| | \-> (d: Double)FooDouble
<console>:10: warning: implicit numeric widening
def elapsed: Foo = (System.nanoTime - 100L).foo
^
| |-- <argument>.toDouble : pt=Double BYVALmode-EXPRmode (silent: method elapsed in $iw) implicits disabled
| | \-> Double
| [adapt] FooDouble adapted to (d: Double)FooDouble based on pt Long => ?{def foo: ?}
| |-- FooLong BYVALmode-EXPRmode-FUNmode-POLYmode (silent: method elapsed in $iw) implicits disabled
| | \-> (l: Long)FooLong
| [adapt] FooLong adapted to (l: Long)FooLong based on pt Long => ?{def foo: ?}
$read.$iw.$iw.FooLong, ) List(), List(), List()
| |-- (l: Long)FooLong EXPRmode-POLYmode-QUALmode (silent: method elapsed in $iw)
| | \-> FooLong
| |-- $line4.$read.$iw.$iw.FooLong(java.this.lang.System.nanoTi... : pt=Foo EXPRmode (site: method elapsed in $iw) |
@adriaanm said: |
@adriaanm said: |
@jrudolph said: |
when compiling with the scalac option
-Ywarn-numeric-widen
we get the following odd warning if the expression is not made up of already evaluated numeric terms:This last one shows that if the expression is assigned then Long is inferred and the typer doesn't complain. But the expression is clearly of the specific type Long, and the warning is unintuitive at best.
This originally came up with the following code:
The text was updated successfully, but these errors were encountered: