Consider the following:
scala> val a:java.lang.Boolean = true
a: java.lang.Boolean = true
scala> val b = true
b: Boolean = true
scala> a == b
res4: Boolean = true
scala> b == a
<console>:8: warning: comparing values of types Boolean
and java.lang.Boolean using `==' will always yield false
b == a
^
res5: Boolean = true
The warning says that it will yield false
but it yields true
.
Scala 2.8.
A bit of source code control archaeology shows that handling of those warnings were improved after 2.8.1. Here is the annotated revisions to the unit tests for those warnings.
https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/test/files/neg/checksensible.scala?annotate=blame&rev=25638
This is compared to rev 19169 in 2.8.1 final that is a lot more basic:
https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_8_1_final/test/files/neg/checksensible.scala
I think this gives a sense that more attention was provided to this after 2.8.1.
Looking at some bug reports, it seems the warning are really just that - hopefully helping identify errors. If you know what you're doing (such as comparing java Boolean and scala Boolean), then you can ignore.
Interestingly, this has regressed. In recent warning enhancements I must be excluding numerics and missing boolean. The error message in trunk for comparing java.lang.Boolean and Boolean is impressively confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With