Repository navigation
Improve variance measurement - #36261
Conversation
|
TypeScript Bot (@typescript-bot) test this |
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at b453606. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized community code test suite on this PR at b453606. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at b453606. You can monitor the build here. It should now contribute to this PR's status checks. |
Wesley Wigham (weswigham)
left a comment
There was a problem hiding this comment.
Seems straightforward to me.
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
|
Community test failures appear to be preexisting conditions. Other tests are clean. |
This PR improves variance measurement for generic types. Previously we'd default to covariance for recursive references to the same type during variance measurement. Now we instead assume recursive references to be "possibly related" (signaled using
Ternary.Maybe), similarly to what happens when we hit the recursion depth limiter. This effectively means we measure variance only from type parameter occurrences that aren't nested in recursive instantiations of the generic type.Previously, a type like the following:
would be measured as invariant in
T: We would correctly measure the reference toTin thefproperty as contravariant, but then the recursive reference toFooin thegproperty would default to covariance and we'd end up with a combined invariant result. We now correctly measure the type as contravariant inT:We furthermore now correctly measure unwitnessed type parameters in recursive references as independent:
We could potentially further improve variance measurement by structurally exploring recursive references to some depth other than zero, but we already know that the limit of 5 imposed by the recursion depth limiter is too high to prevent runaway recursion in some of our test suites.
Fixes #35805.