Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax variance restrictions on constraints on class type parameters
Summary: Covariant and contravariant parameters can safely appear anywhere in "as" and "super" constraints on class type parameters. Currently an "as" constraint is treated as a negative (contravariant) position, and a "super" constraint as a positive (covariant) position. This is necessary for constraints on *method* type parameters but there is no soundness requirement for this check on class type parameters. (See http://research.microsoft.com/pubs/64042/ecoop06.pdf for a soundness theorem that proves it.) Reviewed By: dlreeves Differential Revision: D3235459 fb-gh-sync-id: 483a61d9ddc1201c31a9ef870daaa4a366cc5693 fbshipit-source-id: 483a61d9ddc1201c31a9ef870daaa4a366cc5693
- Loading branch information
1 parent
784ea81
commit 7f14eab
Showing
5 changed files
with
27 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
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,10 @@ | ||
<?hh // strict | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
interface Box<+T> { | ||
public function get(): T; | ||
} | ||
|
||
interface BoxFactory<+T, +Tbox as Box<T>> { | ||
public function make(): Tbox; | ||
} |
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 @@ | ||
No errors |
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