I have a barrel with several classes and there is a class hierarchy like below:
RollingQueue.mc file
module MonkeyMath { (:rollingQueue) public class RollingQueue { ... } }
RollingSum.mc file
module MonkeyMath { (:rollingSum) public class RollingSum extends RollingQueue { ... } }
RollingAverage.mc file
module MonkeyMath { (:rollingAverage) public class RollingAverage extends RollingSum { ... } }
And then in barrels.jungle file in my application I'm including all these 3 annotations in order to be able to use the RollingAverage class:
base.MonkeyMath.annotations = rollingQueue;rollingSum;rollingAverage
Everything works fine. But, since I'm an end-user of the barrel, in an ideal world I shouldn't care about the barrel's inner structure and inheritance - if I only use the RollingAverage class I may only want to include the :rollingAverage annotation. In order to achieve this I tried to apply the following changes:
RollingQueue.mc file
module MonkeyMath { (:rollingQueue :rollingSum :rollingAverage) public class RollingQueue { ... } }
RollingSum.mc file
module MonkeyMath { (:rollingSum :rollingAverage) public class RollingSum extends RollingQueue { ... } }
RollingAverage.mc file
module MonkeyMath { (:rollingAverage) public class RollingAverage extends RollingSum { ... } }
App barrels.jungle file:
base.MonkeyMath.annotations = rollingAverage
This looks logical to me - if some annotation is selected then each class marked with this annotation should be included in the build.
But when I try to compile my code I'm getting errors like these:
ERROR: Cannot resolve super class name 'RollingSum'.
ERROR: Undefined symbol ':RollingSum' detected.
Question 1: Am I doing something wrong or there is no other way than include all 3 annotations in my barrels.jungle file even if I never directly work with superclasses in my app code?
Question 2: There is the following text in the developer guide for barrels:
Developers can use annotations to denote sub-modules within their Barrels. Sub-modules with annotations (i.e. the
(:Bars)
annotation above) allow developers to import certain sections of code without importing the entire Barrel.
Does inclusion work for classes, like in my case, or only for sub-modules?
In the <app-folder>/bin/external-mir folder I see all the classes that are present in the barrel, so have no idea which barrel classes are included in the PRG file - all barrel classes, or only classes marked with annotations from barrels.jungle file.