Почему так странно предупреждение?Несогласованность проверки нулевого равенства scala 2.11.7
scala> null.asInstanceOf[Double]
res0: Double = 0.0
scala> null.asInstanceOf[Double] == null
<console>:11: warning: comparing values of types
Double and Null using `==' will always yield !!!!false!!!!
null.asInstanceOf[Double] == null
^
res1: Boolean = true //!!!!
scala> 0.0 == null
<console>:11: warning: comparing values of types Double and Null using `==' will always yield false
0.0 == null
^
res2: Boolean = false
scala> null.asInstanceOf[Double] == 0.0
res6: Boolean = true
scala> val a = null.asInstanceOf[Double]
a: Double = 0.0
scala> a == null
<console>:12: warning: comparing values of types Double and Null using `==' will always yield false
a == null
^
res7: Boolean = false
P.S. То же самое для Int
и Long
PS2 Это не дубликат - проблема здесь заключается в том, что бокс не происходит вообще, независимо от asInstanceOf
(как вы можете видеть из моего ответа) + предупреждающее сообщение не соответствует
HTTP://stackoverflow.com/questions/10749010/if-an-int-cant-be-null-what-does-null-asinstanceofint-mean –
Хотя я не могу найти ничего в спецификации, которая явно согласуется с ответ. –