This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Support class constraints with multiple dependencies #1402
Merged
Merged
Conversation
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
cesarzc
reviewed
Apr 6, 2022
cesarzc
reviewed
Apr 6, 2022
@samarsha from our conversation and looking at this PR, it doesn't seem like there's any breaking chance but just wanted to double check, is this correct? |
Yes, I don't think it's breaking. |
cesarzc
approved these changes
Apr 7, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
During type inference, the compiler accumulates classes that a type needs to be part of. If the type is a variable, it waits until the variable has a substitution before checking if the class constraint is satisfied. Before this PR, the compiler only knew how to wait for one variable to be ready before checking a constraint. This has been generalized so that each class constraint can depend on an arbitrary number of types.
In particular,
Index<'container, 'index, 'item>
needs to know both'container
and'index
before it can determine'item
. Before this PR,Index
was checked as soon as'container
was known, even if'index
was not known. This resolves #1377.Also did some refactoring within the TypeInference folder, including moving some things out of InferenceContext.fs to keep the file from getting too big, as well as treating subtype/equal/supertype assertions as another type of constraint (so the
Match
method was absorbed intoConstrain
).