Sorry to continue to answer my own question, but ... Another possibility, like a crazy one, would be to create some kind of lock and key for the method that I want to make private, similar to SingletonEnforcer , which is often used in AS3.
// IThing.as interface IThing { function thisMethodIsPublic():void; function thisMethodShouldOnlyBeVisibleToCertainClasses(key:InternalKey):void; } // InternalKey.as internal class InternalKey {}
This seems redundant to me, but I tested it and it works! Classes external to InternalKey can see this method, but cannot call it. It also ensures that the interface uses the method in question instead of resorting to casting to the second interface.
It is also possible that the second interface is an internal interface instead of using an internal key.
internal interface IInternalThing extends IThing { function thisMethodShouldOnlyBeVisibleToCertainClasses():void; }
In fact, both of them are not quite what I need, because I wanted to make the method open for the nested package in the package where IThing will be, so basically I want to use custom namespaces here, but I canβt, Me, you may have to move the classes in the nested package back to the same pacakge as IThing .
source share