Acknowledged
CIQQA-3908

bug: compiler doesn't accept object with non nullable field where nullable field is expected in interface

typedef ISportProfile as interface {
    var sport as Activity.Sport?; // either nullable or not
    var subSport as Activity.SubSport?;
};

function useMeters(sportProfile as ISportProfile?) as Boolean {
    return sportProfile != null && /*sportProfile.sport == Activity.SPORT_RUNNING &&*/ sportProfile.subSport == Activity.SUB_SPORT_TRACK;
}

function foo() as Void {
    var currentWorkoutStepInfo = Activity.getCurrentWorkoutStep();
    var use1 = useMeters(currentWorkoutStepInfo /* as ISportProfile? */);
    var profileInfo = Activity.getProfileInfo();
    var use2 = useMeters(profileInfo);
}

depending whether I add or remove the "?" on the sport field in the interface I get a compilation error either because I pass WorkoutStepInfo that has sport as Sport or because I pass ProfileInfo that has sport as Sport or Null. Is there a way to make both work with strict type check?

ERROR: enduro3: Foo.mc:12,16: Passing 'PolyType<Null or $.Toybox.Activity.WorkoutStepInfo>' as parameter 1 of poly type 'PolyType<Null or interface { var subSport as Null or $.Toybox.Activity.SubSport; var sport as Null or $.Toybox.Activity.Sport; }>'.

or

ERROR: enduro3: Foo.mc:14,20: Invalid '$.Toybox.Activity.ProfileInfo' passed as parameter 1 of type 'PolyType<Null or interface { var subSport as Null or $.Toybox.Activity.SubSport; var sport as $.Toybox.Activity.Sport; }>'.

I feel like having a field's type "Foo?" and passing an object with that field as "Foo" should be allowed.

SDK 8.4.1, strict type check

see:  interface, nullable field, strict type check