import Toybox.Application; import Toybox.Lang; import Toybox.WatchUi; (:background) class MyApp extends Application.AppBase { hidden var view as MyView?; function initialize() { AppBase.initialize(); } (:typecheck(false)) function getInitialView() as Array<Views or InputDelegates>? { self.view = new MyView(); return [ self.view ] as Array<Views or InputDelegates>; } function onSettingsChanged() as Void { if (view != null && isRunningInForeground()) { view.onSettingsChanged(1); } } } (:background) function isRunningInForeground() as Boolean { return $ has :getApp; } function getApp() as GoalDFApp { return Application.getApp() as GoalDFApp; } class MyView extends WatchUi.Datafield { function initialize() { onSettingsChanged(0); } public function onSettingsChanged(settingsChangedFrom as Number) as Void { } }
When compiling with
project.typecheck = 3
I get these errors:
ERROR: fr955: MyApp.mc:65,12: Value 'onSettingsChanged' not available in all function scopes.
ERROR: fr955: MyApp.mc:65,12: Cannot find symbol ':onSettingsChanged' on type 'Null'.
ERROR: fr955: MyApp.mc:65,12: Cannot find symbol ':onSettingsChanged' on type 'Null'.
However when setting typecheck to 0, 1 or 2 it compiles.
SDK 7.1.1
UPDATE: actually there's another similar bug. When I change the code to be system7 compatible:
function getInitialView() as [Views] or [ Views, InputDelegates ] { view = new MyView(); return [ self.view ]; }
then with typecheck:3 I get:
ERROR: fr955: MyApp.mc:33,8: Value 'MyView' not available in all function scopes.
ERROR: fr955: MyApp.mc:33,8: Value 'initialize' not available in all function scopes.
UPDATE2:
even if I add
(:typecheck(disableBackgroundCheck)) then the null check fails:
(:typecheck(disableBackgroundCheck)) function onSettingsChanged() as Void { if (view != null && isRunningInForeground()) { view.onSettingsChanged(1); } }
ERROR: fr955: MyApp.mc:70,12: Cannot find symbol ':onSettingsChanged' on type 'Null'.