-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Statics subtyping (RFC: Newable<.>
to indicate constructor subtyping)
#1847
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db81278
Fix Class<> annotations for subtyping, and require subtyping on inter…
popham 8289902
Update test expectations
popham fe50291
Distribute ConstructorT across intersections
popham b556dbc
Distribute `constructor` lookups across intersections
popham 7a85ad9
Forbid Class<SomeClass>~>SomeInterface flows (require Class<> qualifi…
popham d81a8eb
Alternate, less BS ConstructorT on intersections
popham a692764
ClassT~>ClassT implies unidirectional InstanceT~>InstanceT
popham d2a3d31
Unbump some trivial changes
popham 492fc1e
Fixes #1852
popham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,24 @@ | ||
//@flow | ||
|
||
class A {} | ||
|
||
interface I { | ||
m1(): string; | ||
static sm1(): number; | ||
} | ||
|
||
function fn(): Class<A> & Class<I> { | ||
return class K extends A { | ||
m1() { return "a string"; } | ||
static sm1() { return 1; } | ||
} | ||
} | ||
|
||
function gn(): Class<A> & Class<I> { | ||
return class K extends A {} | ||
} | ||
|
||
var X = fn(); | ||
var x = new X(); | ||
|
||
var Y = gn(); |
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
test2.js:35 | ||
35: static gn(): Class<Y> { //NG | ||
^ Y. This type is incompatible with | ||
29: static gn(): Class<this> { | ||
^^^^ some incompatible instantiation of `this` | ||
|
||
Found 0 errors | ||
|
||
Found 1 error |
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,40 @@ | ||
class A {} | ||
class B extends A {} | ||
|
||
class K { | ||
static gn() { | ||
return this; | ||
} | ||
} | ||
|
||
class L extends K { | ||
static gn() { // NG Bug: False positive. | ||
return L; | ||
} | ||
} | ||
|
||
class W { | ||
fn(): Class<A> { | ||
return B; | ||
} | ||
static fn(): Class<A> { | ||
return B; | ||
} | ||
static gn(): Class<W> { | ||
return W; | ||
} | ||
} | ||
|
||
class X extends W { | ||
static gn(): Class<this> { | ||
return this; | ||
} | ||
} | ||
|
||
class Y extends X { | ||
static gn(): Class<Y> { //NG | ||
return Y; | ||
} | ||
} | ||
|
||
var a: Class<W> = X.gn(); |
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 @@ | ||
interface I { | ||
fn(): number; | ||
static gn(): number; | ||
} | ||
|
||
class A {} | ||
var a = new A(); | ||
var p: A & I = a; // NG | ||
var P: Class<A> & Class<I> = A; // NG | ||
|
||
class B extends A { | ||
fn(): number { | ||
return 1; | ||
} | ||
static gn(): number { | ||
return 2; | ||
} | ||
} | ||
var b = new B(); | ||
var q: A & I = b; // OK | ||
var Q: Class<A> & Class<I> = B; // OK |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generalize with an
is_set_op_distributive
gate onu
, and handleUnionT
too.