Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restrict @:allow(some.pack) to types located in that package only (#8306
- Loading branch information
1 parent
8a36770
commit a05769a
Showing
7 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pack.BasePack; | ||
import pack.IPack; | ||
import pack.Pvt; | ||
|
||
class Main { | ||
static function main() { | ||
|
||
} | ||
} | ||
|
||
class Sub extends BasePack implements IPack { | ||
override public function test() { | ||
// should fail, because it allows access to specific package - pack | ||
Pvt1.testPack(); | ||
Pvt2.testPack(); | ||
// should pass, because it allows access to all instances of pack.BasePack (including descendant classes) | ||
Pvt2.testClass(); | ||
// should pass, because it allows access to all implementers of pack.IPack | ||
Pvt2.testInterface(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-main Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Main.hx:14: characters 3-16 : Cannot access private field testPack | ||
Main.hx:15: characters 3-16 : Cannot access private field testPack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pack; | ||
|
||
import pack.Pvt; | ||
|
||
class BasePack { | ||
public function new() {} | ||
|
||
public function test() { | ||
Pvt1.testPack(); | ||
Pvt2.testPack(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package pack; | ||
|
||
interface IPack {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package pack; | ||
|
||
@:allow(pack) | ||
class Pvt1 { | ||
static function testPack() {} | ||
} | ||
|
||
class Pvt2 { | ||
@:allow(pack) | ||
static function testPack() {} | ||
|
||
@:allow(pack.BasePack) | ||
static function testClass() {} | ||
|
||
@:allow(pack.IPack) | ||
static function testInterface() {} | ||
} |