You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is related to #5648, warnings on comparisons.
There is one edge-casey bug: (new Kase() == kaseAlias) causes the "fresh object" warning. It should be either no warning or "unrelated types" warning, depending on the types.
The similar comparison (finalKase == kaseAlias) will emit "always yield false" (if there is no subtype relationship) instead of the weaker "unrelated types" warnings. (Can be true if the types are siblings extending the case class.)
The useful improvement would be to handle comparisons between case classes again, since if the case classes are different they can't satisfy the synthetic equals. (Some(1) == Thing(1))
A couple of related improvements would be to tighten up "fresh object" warnings, of the form (new Some(1) == None).
scala>:paste
// Entering paste mode (ctrl-D to finish)// aliastraitThingy// sibling classes that extend a case classcaseclassThing(i: Int)
classThingOne(x:Int) extendsThing(x)
classThingTwo(y:Int) extendsThing(y) withThingyfinalclassThingThree(z:Int) extendsThing(z)
valt1=newThingOne(11)
valt2:Thingy=newThingTwo(11)
valt4=newThingThree(11)
// Exiting paste mode, now interpreting.
defined traitThingy
defined classThing
defined classThingOne
defined classThingTwo
defined classThingThree
t1:ThingOne=Thing(11)
t2:Thingy=Thing(11)
t4:ThingThree=Thing(11)
scala> (newThingTwo(11) == t2)
<console>:13:warning: comparing a fresh objectusing `==' will always yield false
(newThingTwo(11) == t2)
^
res0:Boolean=true
scala> (t4 == t2) // unrelated types
<console>:15:warning: comparing values of types ThingThree and Thingy using `==' will always yield false
(t4 == t2)
^
res1:Boolean=true
scala> (Some(1) ==Thing(1)) // could warn
res2:Boolean=false
I'll prepare a pull if I can type faster than Paul.
The text was updated successfully, but these errors were encountered:
It's not possible to run partest without -deprecation.
Since detecting the warnings requires a neg test with
-Xfatal-warnings, and deprecation terminates the compile.
During a deprecation cycle, it seems necessary to test
deprecated features (e.g., warnings).
(The deprecated feature here was trait extends Kase,
where the case class is parenless.)
I tried supplying a .javaopts file to turn off the default
-deprecation, without success. On a related note, I would
expect to be able to "scalac --deprecation=false".
This is related to #5648, warnings on comparisons.
There is one edge-casey bug: (new Kase() == kaseAlias) causes the "fresh object" warning. It should be either no warning or "unrelated types" warning, depending on the types.
The similar comparison (finalKase == kaseAlias) will emit "always yield false" (if there is no subtype relationship) instead of the weaker "unrelated types" warnings. (Can be true if the types are siblings extending the case class.)
The useful improvement would be to handle comparisons between case classes again, since if the case classes are different they can't satisfy the synthetic equals. (Some(1) == Thing(1))
A couple of related improvements would be to tighten up "fresh object" warnings, of the form (new Some(1) == None).
I'll prepare a pull if I can type faster than Paul.
The text was updated successfully, but these errors were encountered: