forum > Inconsistency with Private Access
-
ryan May 10 at 22:35
I found this odd little inconsistency while trying to access the private field/method of a object that shares my objects base class.
Here's the code:
class Base { private function foo():Void { } } class Foo extends Base { public function doSomething(bar:Bar):Void { // Can't call bar.foo(); } } class Bar extends Base { }
So as you can see both of my classes share a common base class. However, I am not able to call a method they both have access to. The code won't compile.
However, if I make the argument a Base object like so:
public function doSomething(bar:Base):Void { bar.foo(); }
It works just fine and compiles.
A strange inconsistency that's going to cause annoying things like:
public function doSomething(bar:Bar):Void { // Do a whole bunch of useful things with bar as a Bar // Forced to convert bar to a Base cast(bar, Base).foo(); }
I hope this gets look at and fixed soon.
Thanks. -
I hope this gets look at and fixed soon.
The best place to report issues or ask technical questions is on our very active google group/forum:https://groups.google.com/forum/#!forum/haxelang
which Justin also nicely embedded in this forum:
http://haxe.org/forum/thread/3665You can check the community page for other places where you can ask help or meet 'haxe-people':
http://haxe.org/comKind regards,
Jan
PS: This forum was mainly created for people that were uncomfortable or not familar or with a mailing list (which we used before me moved to the google group/forum.)
http://lists.motion-twin.com/mailman/listinfo/haxe (it is closed now) -
Looks like a bug, private is accessible with Reflection but should not be in the way you illustrate. Please file bugs here:
-
He already did. :)
http://code.google.com/p/haxe/issues/detail?id=831Jan