Closed ashleymercer closed 9 months ago
Reproduced in scastie here, can confirm this behaviour by switching between Scala 2.13.10 and 2.13.12 in the Build Settings.
EDIT: looks like it compiles fine under 2.13.11 as well, so the regression is fairly recent. I've seen some other tickets in both Scala 2 and 3 around changes to the heuristics for detecting unused parameters, wonder if something has crept in unintended?
The unused implicit is supposed to go unreported because the parameter is required by the signature of the overridden method.
(Explaining to myself before I forget.)
I confirmed that it warns without -Xsource:3
. -Wunused:implicits
is the switch.
The Int
-typed parameter will also warn if the RHS is not deemed a trivial placeholder:
override def fooImplicit2()(implicit i: Int): Int = 42 max -1
I intend to contribute a flag to make those "heuristics" opt-in, since they are deceptive; perhaps the warnings also need a verbose flag to report when warnings are intentionally suppressed.
Awesome! Thanks so much for the quick response on this :)
Reproduction steps
Scala version: 2.13.12
Problem
Under scala 2.13.10 the above compiles just fine without any warnings at all.
Under scala 2.13.12 it gives a (false?) positive for unused parameter only on
FooMock.barImplicit2
- all other cases correctly compile without warnings.Int
, but does occur forExecutionContext
(and possibly other types - but EC was the only one I could find)