Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Model multiple call properties as an intersection of callable objects
Summary:
Before this diff, multiple call properties created a single object type with a
call property which was an intersection of function types.
An object with a callable property can be equivalently viewed as a function with
static fields. Due to this equivalence, typing rules might forward a constraint
from the object to its call property.
It leads to bad behavior if an intersection lower bound is checked against an
object type with an intersection call property, since the latter is unwrapped at
the wrong point.
For example, the constraint `A & B ~> { [[call]]: A & B }` leads to speculation
on the lower bound where either `A` or `B` must be compatible with the callable
object type, and neither `A` nor `B` are compatible with `A & B`.
Instead, it is necessary to decompose the intersection in the upper bound first.
This diff accomplishes this by modeling the above scenario as an intersection of
object types, e.g. `{ [[call]]: A } & { [[call]]: B }`, which will be decomposed
first.
Reviewed By: panagosg7
Differential Revision: D14702329
fbshipit-source-id: c1ebcb1373787cea33c8b8fc233ae1c1bfbe0c4d- Loading branch information
1 parent
e1f6913
commit b9e26fd
Showing
6 changed files
with
129 additions
and
124 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
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