Regression with Type Check set to Strict?

TLDR: I want to use strict type checking at compile-time but end up with multiple errors, such as "Cannot find symbol ':format' on type 'Null'." -- NO, I do NOT want to stick to "Informative" and NO, I do NOT need opinions about whether or not I should do this or if it is necessary. The compiler has the option and I want to use it as it will likely lead to less run-time IQ! errors.

I am trying to clean up the various compiler warnings in one of my projects, with the ultimate goal of moving from "Interactive" to "Strict". I see the  ran into this, posted about it, and apparently it was solved but I don't think was ever fixed for instance attributes. Or if it was, then there was a regression in the type checking. As an example, this code will generate a WARNING or ERROR (depending on the type check setting):

var latestInfo = Sensor.getInfo();
if (latestInfo != null) {
    if (latestInfo.heartRate != null) {
        var heartRateStr = latestInfo.heartRate.format("%0d");
    }
}

The current workaround I've found is to use a local variable, which is both extra code and far less clean. And it shoudn't be necessary.

var latestInfo = Sensor.getInfo();
if (latestInfo != null) {
    var tmpHR = latestInfo.heartRate;
    if (tmpHR != null) {
        heartRateStr = tmpHR.format("%0d");
    }
}


This is happening with SDK 6.2.0

UPDATE: I've posted a bug report: forums.garmin.com/.../strict-type-checking-when-dealing-with-instance-attributes-that-might-be-null

  • I don't think it was ever fixed. The status of one of the 1 year old reports has been changed to Complete, but I guess they either meant some very specific thing, but not the problem we all want to be fixed that code inside if (foo != null) {foo.bar} block or after "if (foo != null && ... foo.bar" we don't get compile time errors, or they fixed it but it also got broken again (probably in the same release they supposedly released the "fix")