Add declarations for internal keyword in direct decl and legacy parsers
[hiphop-php.git] / hphp / hack / test / typecheck / modules / module_inheritance.php
blob37a45c46918cab259bfa8586bd7c7ec817bb319c
1 //// modules.php
2 <?hh
3 <<file:__EnableUnstableFeatures('modules')>>
5 module A {}
6 module B {}
7 //// A.php
8 <?hh
9 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
10 <<file:__EnableUnstableFeatures('modules'), __Module('A')>>
12 class A {
13 public function pub(): void {}
15 <<__Internal>>
16 public function internal(): void {}
19 class A2 extends A {
20 // This is allowed because it's the same module
21 <<__Override, __Internal>>
22 public function internal(): void {}
25 // This is illegal, overriding a public method to be internal
27 class A3 extends A {
28 <<__Override, __Internal>>
29 public function pub(): void {}
32 //// B.php
33 <?hh
34 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
35 <<file:__EnableUnstableFeatures('modules'), __Module('B')>>
37 class B extends A {
38 <<__Override, __Internal>>
39 public function pub(): void {}
43 // This is illegal because it is overriding an internal method from a different
44 // module
45 class B2 extends A {
46 <<__Override, __Internal>>
47 public function internal(): void {}