-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Type inference refactor and improve join orders #20076
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
Changes from 1 commit
475d872
bdcecdf
43b2977
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1229,11 +1229,8 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> { | |
predicate relevantAccessConstraint( | ||
Access a, Declaration target, AccessPosition apos, TypePath path, Type constraint | ||
) { | ||
exists(DeclarationPosition dpos | | ||
accessDeclarationPositionMatch(apos, dpos) and | ||
target = a.getTarget() and | ||
typeParameterConstraintHasTypeParameter(target, dpos, path, _, constraint, _, _) | ||
) | ||
target = a.getTarget() and | ||
typeParameterConstraintHasTypeParameter(target, apos, path, constraint, _, _) | ||
} | ||
|
||
private newtype TRelevantAccess = | ||
|
@@ -1276,12 +1273,11 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> { | |
} | ||
|
||
predicate satisfiesConstraintType( | ||
Access a, AccessPosition apos, TypePath prefix, Type constraint, TypePath path, Type t | ||
Access a, Declaration target, AccessPosition apos, TypePath prefix, Type constraint, | ||
TypePath path, Type t | ||
) { | ||
exists(RelevantAccess at | at = MkRelevantAccess(a, _, apos, prefix) | | ||
SatisfiesConstraint<RelevantAccess, SatisfiesConstraintInput>::satisfiesConstraintType(at, | ||
constraint, path, t) | ||
) | ||
SatisfiesConstraint<RelevantAccess, SatisfiesConstraintInput>::satisfiesConstraintType(MkRelevantAccess(a, | ||
target, apos, prefix), constraint, path, t) | ||
} | ||
} | ||
|
||
|
@@ -1370,37 +1366,38 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> { | |
} | ||
|
||
/** | ||
* Holds if `tp1` and `tp2` are distinct type parameters of `target`, the | ||
* declared type at `dpos` mentions `tp1` at `path1`, `tp1` has a base | ||
* type mention of type `constraint` that mentions `tp2` at the path | ||
* `path2`. | ||
* Holds if the declared type of `target` contains a type parameter at | ||
* `apos` and `pathToConstrained` that must satisfy `constraint` and `tp` | ||
* occurs at `pathToTp` in `constraint`. | ||
* | ||
* For this example | ||
* For example, in | ||
* ```csharp | ||
* interface IFoo<A> { } | ||
* T1 M<T1, T2>(T2 item) where T2 : IFoo<T1> { } | ||
* ``` | ||
* with the method declaration being the target and the for the first | ||
* parameter position, we have the following | ||
* - `path1 = ""`, | ||
* - `tp1 = T2`, | ||
* with the method declaration being the target and with `apos` | ||
* corresponding to `item`, we have the following | ||
* - `pathToConstrained = ""`, | ||
* - `tp = T1`, | ||
* - `constraint = IFoo`, | ||
* - `path2 = "A"`, and | ||
* - `tp2 = T1`. | ||
* - `pathToTp = "A"`. | ||
*/ | ||
pragma[nomagic] | ||
private predicate typeParameterConstraintHasTypeParameter( | ||
Declaration target, DeclarationPosition dpos, TypePath path1, TypeParameter tp1, | ||
Type constraint, TypePath path2, TypeParameter tp2 | ||
Declaration target, AccessPosition apos, TypePath pathToConstrained, Type constraint, | ||
TypePath pathToTp, TypeParameter tp | ||
) { | ||
tp1 = target.getTypeParameter(_) and | ||
tp2 = target.getTypeParameter(_) and | ||
tp1 != tp2 and | ||
tp1 = target.getDeclaredType(dpos, path1) and | ||
exists(TypeMention tm | | ||
tm = getATypeParameterConstraint(tp1) and | ||
tm.resolveTypeAt(path2) = tp2 and | ||
constraint = resolveTypeMentionRoot(tm) | ||
exists(DeclarationPosition dpos, TypeParameter constrainedTp | | ||
accessDeclarationPositionMatch(apos, dpos) and | ||
constrainedTp = target.getTypeParameter(_) and | ||
tp = target.getTypeParameter(_) and | ||
constrainedTp != tp and | ||
constrainedTp = target.getDeclaredType(dpos, pathToConstrained) and | ||
exists(TypeMention tm | | ||
tm = getATypeParameterConstraint(constrainedTp) and | ||
tm.resolveTypeAt(pathToTp) = tp and | ||
constraint = resolveTypeMentionRoot(tm) | ||
) | ||
) | ||
} | ||
|
||
|
@@ -1409,15 +1406,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> { | |
Access a, Declaration target, TypePath path, Type t, TypeParameter tp | ||
) { | ||
not exists(getTypeArgument(a, target, tp, _)) and | ||
target = a.getTarget() and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What has happened to this constraint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. It's implied by |
||
exists( | ||
Type constraint, AccessPosition apos, DeclarationPosition dpos, TypePath pathToTp, | ||
TypePath pathToTp2 | ||
| | ||
accessDeclarationPositionMatch(apos, dpos) and | ||
typeParameterConstraintHasTypeParameter(target, dpos, pathToTp2, _, constraint, pathToTp, | ||
tp) and | ||
AccessConstraint::satisfiesConstraintType(a, apos, pathToTp2, constraint, | ||
exists(Type constraint, AccessPosition apos, TypePath pathToTp, TypePath pathToTp2 | | ||
typeParameterConstraintHasTypeParameter(target, apos, pathToTp2, constraint, pathToTp, tp) and | ||
AccessConstraint::satisfiesConstraintType(a, target, apos, pathToTp2, constraint, | ||
pathToTp.appendInverse(path), t) | ||
) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.