-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requiring methods in interfaces to forgo bodies
Summary: Prior to this diff, the full fidelity parser handled method declarations in interfaces incorrectly: it a) threw error2015 on interface methods without bodies, and b) allowed interface methods to have bodies. In this diff I reversed both of these behaviors. The updated full fidelity parser behavior is demonstrated in test_interface_method_errors.(php/exp). Reviewed By: ericlippert Differential Revision: D5326581 fbshipit-source-id: 0174fda5cf6967069042d41424da97e4b9eecb3f
- Loading branch information
Showing
5 changed files
with
50 additions
and
8 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
3 changes: 3 additions & 0 deletions
3
hphp/hack/test/full_fidelity/cases/test_interface_method_errors.exp
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 @@ | ||
(5,22)-(5,24) A method inside an interface may not have a body. | ||
(9,22)-(9,22) A non-abstract method must have a body. | ||
(14,23)-(14,23) A non-abstract method must have a body. |
16 changes: 16 additions & 0 deletions
16
hphp/hack/test/full_fidelity/cases/test_interface_method_errors.php
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,16 @@ | ||
<?hh // strict | ||
|
||
interface I { | ||
function i1(): int; // legal | ||
function i2(): int { } // error2041 | ||
} | ||
|
||
class C { | ||
function c1(): void; // error2015 | ||
function c2(): void { } // legal | ||
} | ||
|
||
trait T { | ||
function t1() : void; // error2015 | ||
function t2() : void { } // legal | ||
} |
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