When comparing a value class instance with the value itself, I expect a compiler warning the same way as is issued if comparing unrelated objects.
In the example below, the instance of S and 10 are recognized as unrelated (as expected), but the value class instance of T and 10 are not recognized as unrelated (although they are never equal). This is dangerous, since I want to use value classes just for the purpose of having e.g. a type-safe implementation of "Size" that can not be mixed by accident with other Int values. So the compiler should enforce comparing a size like this: "currentFileSize == new Size(10)" (where currentFileSize is an instance of the value type Size). Instead, if I write "currentFileSize == 10", I always get "false" and no warning about it.
scala> s ==10
<console>:10:warning: S and Int are unrelated: they will most likely never compare equal
scala> t ==10
The text was updated successfully, but these errors were encountered: