@@ -41,6 +41,12 @@ private module Input implements InputSig1<Location>, InputSig2<PreTypeMention> {
4141
4242 class TypeAbstraction = TA:: TypeAbstraction ;
4343
44+ predicate typeAbstractionHasAmbigousConstraintAt (
45+ TypeAbstraction abs , Type constraint , TypePath path
46+ ) {
47+ FunctionOverloading:: implHasAmbigousSiblingAt ( abs , constraint .( TraitType ) .getTrait ( ) , path )
48+ }
49+
4450 class TypeArgumentPosition extends TTypeArgumentPosition {
4551 int asMethodTypeArgumentPosition ( ) { this = TMethodTypeArgumentPosition ( result ) }
4652
@@ -127,17 +133,15 @@ private module Input implements InputSig1<Location>, InputSig2<PreTypeMention> {
127133
128134 PreTypeMention getABaseTypeMention ( Type t ) { none ( ) }
129135
130- Type getATypeParameterConstraint ( TypeParameter tp , TypePath path ) {
131- exists ( TypeMention tm | result = tm .getTypeAt ( path ) |
132- tm = tp .( TypeParamTypeParameter ) .getTypeParam ( ) .getATypeBound ( ) .getTypeRepr ( ) or
133- tm = tp .( SelfTypeParameter ) .getTrait ( ) or
134- tm =
135- tp .( ImplTraitTypeTypeParameter )
136- .getImplTraitTypeRepr ( )
137- .getTypeBoundList ( )
138- .getABound ( )
139- .getTypeRepr ( )
140- )
136+ PreTypeMention getATypeParameterConstraint ( TypeParameter tp ) {
137+ result = tp .( TypeParamTypeParameter ) .getTypeParam ( ) .getATypeBound ( ) .getTypeRepr ( ) or
138+ result = tp .( SelfTypeParameter ) .getTrait ( ) or
139+ result =
140+ tp .( ImplTraitTypeTypeParameter )
141+ .getImplTraitTypeRepr ( )
142+ .getTypeBoundList ( )
143+ .getABound ( )
144+ .getTypeRepr ( )
141145 }
142146
143147 /**
@@ -1126,7 +1130,7 @@ private module ContextTyping {
11261130 or
11271131 exists ( TypeParameter mid |
11281132 assocFunctionMentionsTypeParameterAtNonRetPos ( i , f , mid ) and
1129- tp = getATypeParameterConstraint ( mid , _)
1133+ tp = getATypeParameterConstraint ( mid ) . getTypeAt ( _)
11301134 )
11311135 }
11321136
@@ -2237,7 +2241,7 @@ private module MethodResolution {
22372241 }
22382242
22392243 private module MethodCallSatisfiesDerefConstraintInput implements
2240- SatisfiesConstraintInputSig < MethodCallDerefCand >
2244+ SatisfiesTypeInputSig < MethodCallDerefCand >
22412245 {
22422246 pragma [ nomagic]
22432247 predicate relevantConstraint ( MethodCallDerefCand mc , Type constraint ) {
@@ -2247,7 +2251,7 @@ private module MethodResolution {
22472251 }
22482252
22492253 private module MethodCallSatisfiesDerefConstraint =
2250- SatisfiesConstraint < MethodCallDerefCand , MethodCallSatisfiesDerefConstraintInput > ;
2254+ SatisfiesType < MethodCallDerefCand , MethodCallSatisfiesDerefConstraintInput > ;
22512255
22522256 pragma [ nomagic]
22532257 private AssociatedTypeTypeParameter getDerefTargetTypeParameter ( ) {
@@ -3683,21 +3687,20 @@ final private class AwaitTarget extends Expr {
36833687 Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
36843688}
36853689
3686- private module AwaitSatisfiesConstraintInput implements SatisfiesConstraintInputSig < AwaitTarget > {
3690+ private module AwaitSatisfiesTypeInput implements SatisfiesTypeInputSig < AwaitTarget > {
36873691 pragma [ nomagic]
36883692 predicate relevantConstraint ( AwaitTarget term , Type constraint ) {
36893693 exists ( term ) and
36903694 constraint .( TraitType ) .getTrait ( ) instanceof FutureTrait
36913695 }
36923696}
36933697
3694- private module AwaitSatisfiesConstraint =
3695- SatisfiesConstraint< AwaitTarget , AwaitSatisfiesConstraintInput > ;
3698+ private module AwaitSatisfiesType = SatisfiesType< AwaitTarget , AwaitSatisfiesTypeInput > ;
36963699
36973700pragma [ nomagic]
36983701private Type inferAwaitExprType ( AstNode n , TypePath path ) {
36993702 exists ( TypePath exprPath |
3700- AwaitSatisfiesConstraint :: satisfiesConstraintType ( n .( AwaitExpr ) .getExpr ( ) , _, exprPath , result ) and
3703+ AwaitSatisfiesType :: satisfiesConstraintType ( n .( AwaitExpr ) .getExpr ( ) , _, exprPath , result ) and
37013704 exprPath .isCons ( getFutureOutputTypeParameter ( ) , path )
37023705 )
37033706}
@@ -3876,9 +3879,7 @@ final private class ForIterableExpr extends Expr {
38763879 Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
38773880}
38783881
3879- private module ForIterableSatisfiesConstraintInput implements
3880- SatisfiesConstraintInputSig< ForIterableExpr >
3881- {
3882+ private module ForIterableSatisfiesTypeInput implements SatisfiesTypeInputSig< ForIterableExpr > {
38823883 predicate relevantConstraint ( ForIterableExpr term , Type constraint ) {
38833884 exists ( term ) and
38843885 exists ( Trait t | t = constraint .( TraitType ) .getTrait ( ) |
@@ -3899,15 +3900,15 @@ private AssociatedTypeTypeParameter getIntoIteratorItemTypeParameter() {
38993900 result = getAssociatedTypeTypeParameter ( any ( IntoIteratorTrait t ) .getItemType ( ) )
39003901}
39013902
3902- private module ForIterableSatisfiesConstraint =
3903- SatisfiesConstraint < ForIterableExpr , ForIterableSatisfiesConstraintInput > ;
3903+ private module ForIterableSatisfiesType =
3904+ SatisfiesType < ForIterableExpr , ForIterableSatisfiesTypeInput > ;
39043905
39053906pragma [ nomagic]
39063907private Type inferForLoopExprType ( AstNode n , TypePath path ) {
39073908 // type of iterable -> type of pattern (loop variable)
39083909 exists ( ForExpr fe , TypePath exprPath , AssociatedTypeTypeParameter tp |
39093910 n = fe .getPat ( ) and
3910- ForIterableSatisfiesConstraint :: satisfiesConstraintType ( fe .getIterable ( ) , _, exprPath , result ) and
3911+ ForIterableSatisfiesType :: satisfiesConstraintType ( fe .getIterable ( ) , _, exprPath , result ) and
39113912 exprPath .isCons ( tp , path )
39123913 |
39133914 tp = getIntoIteratorItemTypeParameter ( )
@@ -3933,21 +3934,20 @@ final private class InvokedClosureExpr extends Expr {
39333934 CallExpr getCall ( ) { result = call }
39343935}
39353936
3936- private module InvokedClosureSatisfiesConstraintInput implements
3937- SatisfiesConstraintInputSig< InvokedClosureExpr >
3937+ private module InvokedClosureSatisfiesTypeInput implements SatisfiesTypeInputSig< InvokedClosureExpr >
39383938{
39393939 predicate relevantConstraint ( InvokedClosureExpr term , Type constraint ) {
39403940 exists ( term ) and
39413941 constraint .( TraitType ) .getTrait ( ) instanceof FnOnceTrait
39423942 }
39433943}
39443944
3945- private module InvokedClosureSatisfiesConstraint =
3946- SatisfiesConstraint < InvokedClosureExpr , InvokedClosureSatisfiesConstraintInput > ;
3945+ private module InvokedClosureSatisfiesType =
3946+ SatisfiesType < InvokedClosureExpr , InvokedClosureSatisfiesTypeInput > ;
39473947
39483948/** Gets the type of `ce` when viewed as an implementation of `FnOnce`. */
39493949private Type invokedClosureFnTypeAt ( InvokedClosureExpr ce , TypePath path ) {
3950- InvokedClosureSatisfiesConstraint :: satisfiesConstraintType ( ce , _, path , result )
3950+ InvokedClosureSatisfiesType :: satisfiesConstraintType ( ce , _, path , result )
39513951}
39523952
39533953/**
0 commit comments