Noticed the following during the refactoring:
import Toybox.Lang;
function f(x as Number) as Number {
if ((x as String) == "") { // "The type Number cannot be converted to String because they have nothing in common" - OK
return 0;
} else if (x instanceof String) { // No warnings - NOK
return x.length();
} else {
return x;
}
}
PMC gives warning about bad cast x as String, but doesn't about bad condition x instanceof String. Is it possible to improve instanceof check to work the same way as the as?
Noticed the following during the refactoring:
PMC gives warning about bad cast
x as String, but doesn't about bad conditionx instanceof String. Is it possible to improveinstanceofcheck to work the same way as theas?