Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow] refine opaque type bounds in type guard refinement
Summary: Before this change opaque types were not treated in any special way during type guard refinement. This meant that we would get stuck with some awkward intersections with the guard type, which would very frequently lead to unexpected errors. This diff applies a similar approach to the one followed for refinement of generics, where we refine the bound of the generic instead. In the case of opaque types we refine the super and underlying type instead. If there is no super type, we refine `mixed` which is equivalent to using the guard type as super type. Changelog: [fix] refining type guards with opaque types will now refine the general type (example of code that used to fail before, but now passes: [try-Flow](https://flow.org/try/#1N4Igxg9gdgZglgcxALlAIwIZoKYBsD6uEEAztvhgE6UYCe+JADpdhgCYowa5kA0I2KAFcAtiRQAXSkOz9sADwxgJ+NPTbYuQ3BMnTZA+Y2yU4IwRO4A6SFBIrGVDGM7c+h46fNRLuKxJIGWh8MeT0ZfhYlCStpHzNsFBAMIQkIEQwJODAQfiEyfBE4eWw2fDgofDBMsAALfAA3KjgsXGxxZC4eAw0G-GhcWn9aY3wWZldu-g1mbGqJUoBaCRHEzrcDEgBrbAk62kXhXFxJ923d-cPRHEpTgyEoMDaqZdW7vKgoOfaSKgOKpqmDA+d4gB5fMA-P6LCCMLLQbiLOoYCqgh6-GDYRYIXYLSgkRZkCR4jpddwPfJLZjpOBkO4AX34kA0SQAOhJWT5VgACACCAB4ACoAPm5AF5ucBuQBqAAkspWxmQ3IAjLxuU1cDJlYLufTuQAfSUy+WK7DKgBM6s12u5uvpAG5OWbuQAhIWiiUCkVOqAaJ5UbDc2EYACOMm5LoA8h7fS6AMIe8VupNGmM+zmc-24QPcmAPZRwaDc2nukUACkgIkYqXN3MTIoAlMqqzWFiWSCmM1BOfnHvCoJH2hIVeWbXXE0USmxhc2NRA4GxJZzuSWYNzy6Wx9wZI3G8vB6vubZ7Nz8Crk+PuRhO+6p6VhQ7VwB6Z-cylLtLcnDBrZ0FdHieEhnhayp3sUD6Xju2BPtyr7clAEDAcC3ImJQECUNeUC0NyIgYdgAH0pyRE9rABYDkO9gWuW+7AABq4ugAylIFQIPGyaJvYphQAgj70ZGPLMdxCCusm7pcaxfGHqufaFsWaDblqdZCax8a0fxR5rhuW7jnuB6aQZgHQKe55QUp16dipPGurB8GIchg5oRhWE4XhLAaYZx7GcB+CgdyVkiWZMi2W+9lYah1DOcCrn4R5q4kZpJH0rkIANCYJBFlASQNAADFYFoAKwAGxWDlID0kAA)) Reviewed By: SamChou19815 Differential Revision: D67264811 fbshipit-source-id: d185c9f6084cd08873f5039eba4c2f9589d15641
- Loading branch information