SHOW:
|
|
- or go back to the newest paste.
| 1 | ||
| 2 | class Main | |
| 3 | {
| |
| 4 | public static function main() | |
| 5 | - | var t0 = new Test(); |
| 5 | + | |
| 6 | - | var t1 = new Test(t0); |
| 6 | + | var a = new Test(); |
| 7 | - | t1.check(); |
| 7 | + | var b = new Test(); |
| 8 | a.checkTest(b); | |
| 9 | ||
| 10 | var c = new Foo(); | |
| 11 | a.checkFoo(c); | |
| 12 | } | |
| 13 | - | var t:Test; |
| 13 | + | |
| 14 | - | public function new(?t:Test) |
| 14 | + | |
| 15 | {
| |
| 16 | - | this.t = t; |
| 16 | + | public function new() |
| 17 | {
| |
| 18 | - | public function check():Void |
| 18 | + | |
| 19 | public function checkTest(p:Test):Void | |
| 20 | - | if(t!=null) |
| 20 | + | |
| 21 | - | {
|
| 21 | + | p.test();//t should not have access to private function test |
| 22 | - | t.test();//t should have no access to private function test |
| 22 | + | |
| 23 | - | } |
| 23 | + | public function checkFoo(p:Foo):Void |
| 24 | {
| |
| 25 | p.test();//works as expected :Cannot access to private field test | |
| 26 | } | |
| 27 | private function test():Void | |
| 28 | {
| |
| 29 | trace("hello");
| |
| 30 | } | |
| 31 | } | |
| 32 | class Foo | |
| 33 | {
| |
| 34 | public function new() | |
| 35 | {
| |
| 36 | } | |
| 37 | private function test():Void | |
| 38 | {
| |
| 39 | trace("hello");
| |
| 40 | } | |
| 41 | } |