I am getting a bogus circular depency error. My app has a dependency on my barrel. The code of my barrel is shown below. My barrel has a global variable initialized to an instance of InitClass, which triggers the execution of the corresponding constructor when the module is first loaded. This constructor registers a sensorData listener callback. The call to Sensor.registerSensorDataListener() is what is causing the circular dependency error. This seems to be a problem with referencing that particular method and not the entire Sensor module. I know this because if I replace the call to Sensor.registerSensorDataListener() with the following line of code
System.println(Sensor.SENSOR_BIKEPOWER);
Then the code compiles fine and I do not get the circular dependency error. What I think may be happening is that the system is treating the "options" parameter as dependency that the Sensor module is having on my barrel, which is clearly incorrect.
module MyBarrel { (:MySubModule) module MySubModule { using Toybox.Sensor; var options = { :period => 1, :accelerometer => { :enabled => true, :sampleRate => 25, :includePitch => true }, :heartBeatIntervals => { :enabled => false } }; var init = new InitClass(); class InitClass { function initialize() { Sensor.registerSensorDataListener(method(:callback), options); } function callback(sensorData) { } } } }