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
Lint select from Unit
, or Int
that incurs widening
#10372
Conversation
Some current inconsistency.
where With the new warning, the current warning is less correct. |
It warns in two spots that specialize The other thought is that (as with the current warning), any promotion is dubious, it doesn't matter which member is selected. Then just need |
efd7fd9
to
b84df96
Compare
The check is only at typer, which gives a pass to
Not sure why it was deemed bad to allow Something became |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and very useful.
|
||
val sym = tree.symbol orElse member(qual.tpe, name) orElse inCompanionForJavaStatic(qual.tpe.typeSymbol, name) | ||
if ((sym eq NoSymbol) && name != nme.CONSTRUCTOR && mode.inAny(EXPRmode | PATTERNmode)) { | ||
// symbol not found? --> try to convert implicitly to a type that does have the required | ||
// member. Added `| PATTERNmode` to allow enrichment in patterns (so we can add e.g., an | ||
// xml member to StringContext, which in turn has an unapply[Seq] method) | ||
|
||
def checkDubiousAdaptation(sel: Tree): Unit = if (!isPastTyper && settings.lintNumericMethods) { | ||
val dubious = ScalaIntegralValueClasses(qualTp.typeSymbol) && ( | ||
sel.symbol.owner.eq(BoxedFloatClass) || sel.symbol.owner.eq(RichFloatClass)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long.isNaN
goes through float2Float(long.toFloat)
, not double2Double
, so this seems to cover it all.
b84df96
to
905c92f
Compare
Rebased, and enhanced
It would be ideal if The option also adds
In case of selection failure,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Unit
, or Int
that incurs widening
Fixes scala/bug#12728