@@ -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 /**
@@ -1170,7 +1174,7 @@ private module ContextTyping {
11701174 or
11711175 exists ( TypeParameter mid |
11721176 assocFunctionMentionsTypeParameterAtNonRetPos ( i , f , mid ) and
1173- tp = getATypeParameterConstraint ( mid , _)
1177+ tp = getATypeParameterConstraint ( mid ) . getTypeAt ( _)
11741178 )
11751179 }
11761180
@@ -2544,8 +2548,7 @@ private module AssocFunctionResolution {
25442548 Location getLocation ( ) { result = afc .getLocation ( ) }
25452549 }
25462550
2547- private module CallSatisfiesDerefConstraintInput implements
2548- SatisfiesConstraintInputSig< CallDerefCand >
2551+ private module CallSatisfiesDerefConstraintInput implements SatisfiesTypeInputSig< CallDerefCand >
25492552 {
25502553 pragma [ nomagic]
25512554 predicate relevantConstraint ( CallDerefCand mc , Type constraint ) {
@@ -2555,7 +2558,7 @@ private module AssocFunctionResolution {
25552558 }
25562559
25572560 private module CallSatisfiesDerefConstraint =
2558- SatisfiesConstraint < CallDerefCand , CallSatisfiesDerefConstraintInput > ;
2561+ SatisfiesType < CallDerefCand , CallSatisfiesDerefConstraintInput > ;
25592562
25602563 pragma [ nomagic]
25612564 private AssociatedTypeTypeParameter getDerefTargetTypeParameter ( ) {
@@ -3586,21 +3589,20 @@ final private class AwaitTarget extends Expr {
35863589 Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
35873590}
35883591
3589- private module AwaitSatisfiesConstraintInput implements SatisfiesConstraintInputSig < AwaitTarget > {
3592+ private module AwaitSatisfiesTypeInput implements SatisfiesTypeInputSig < AwaitTarget > {
35903593 pragma [ nomagic]
35913594 predicate relevantConstraint ( AwaitTarget term , Type constraint ) {
35923595 exists ( term ) and
35933596 constraint .( TraitType ) .getTrait ( ) instanceof FutureTrait
35943597 }
35953598}
35963599
3597- private module AwaitSatisfiesConstraint =
3598- SatisfiesConstraint< AwaitTarget , AwaitSatisfiesConstraintInput > ;
3600+ private module AwaitSatisfiesType = SatisfiesType< AwaitTarget , AwaitSatisfiesTypeInput > ;
35993601
36003602pragma [ nomagic]
36013603private Type inferAwaitExprType ( AstNode n , TypePath path ) {
36023604 exists ( TypePath exprPath |
3603- AwaitSatisfiesConstraint :: satisfiesConstraintType ( n .( AwaitExpr ) .getExpr ( ) , _, exprPath , result ) and
3605+ AwaitSatisfiesType :: satisfiesConstraintType ( n .( AwaitExpr ) .getExpr ( ) , _, exprPath , result ) and
36043606 exprPath .isCons ( getFutureOutputTypeParameter ( ) , path )
36053607 )
36063608}
@@ -3779,9 +3781,7 @@ final private class ForIterableExpr extends Expr {
37793781 Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
37803782}
37813783
3782- private module ForIterableSatisfiesConstraintInput implements
3783- SatisfiesConstraintInputSig< ForIterableExpr >
3784- {
3784+ private module ForIterableSatisfiesTypeInput implements SatisfiesTypeInputSig< ForIterableExpr > {
37853785 predicate relevantConstraint ( ForIterableExpr term , Type constraint ) {
37863786 exists ( term ) and
37873787 exists ( Trait t | t = constraint .( TraitType ) .getTrait ( ) |
@@ -3802,15 +3802,15 @@ private AssociatedTypeTypeParameter getIntoIteratorItemTypeParameter() {
38023802 result = getAssociatedTypeTypeParameter ( any ( IntoIteratorTrait t ) .getItemType ( ) )
38033803}
38043804
3805- private module ForIterableSatisfiesConstraint =
3806- SatisfiesConstraint < ForIterableExpr , ForIterableSatisfiesConstraintInput > ;
3805+ private module ForIterableSatisfiesType =
3806+ SatisfiesType < ForIterableExpr , ForIterableSatisfiesTypeInput > ;
38073807
38083808pragma [ nomagic]
38093809private Type inferForLoopExprType ( AstNode n , TypePath path ) {
38103810 // type of iterable -> type of pattern (loop variable)
38113811 exists ( ForExpr fe , TypePath exprPath , AssociatedTypeTypeParameter tp |
38123812 n = fe .getPat ( ) and
3813- ForIterableSatisfiesConstraint :: satisfiesConstraintType ( fe .getIterable ( ) , _, exprPath , result ) and
3813+ ForIterableSatisfiesType :: satisfiesConstraintType ( fe .getIterable ( ) , _, exprPath , result ) and
38143814 exprPath .isCons ( tp , path )
38153815 |
38163816 tp = getIntoIteratorItemTypeParameter ( )
@@ -3836,21 +3836,20 @@ final private class InvokedClosureExpr extends Expr {
38363836 CallExpr getCall ( ) { result = call }
38373837}
38383838
3839- private module InvokedClosureSatisfiesConstraintInput implements
3840- SatisfiesConstraintInputSig< InvokedClosureExpr >
3839+ private module InvokedClosureSatisfiesTypeInput implements SatisfiesTypeInputSig< InvokedClosureExpr >
38413840{
38423841 predicate relevantConstraint ( InvokedClosureExpr term , Type constraint ) {
38433842 exists ( term ) and
38443843 constraint .( TraitType ) .getTrait ( ) instanceof FnOnceTrait
38453844 }
38463845}
38473846
3848- private module InvokedClosureSatisfiesConstraint =
3849- SatisfiesConstraint < InvokedClosureExpr , InvokedClosureSatisfiesConstraintInput > ;
3847+ private module InvokedClosureSatisfiesType =
3848+ SatisfiesType < InvokedClosureExpr , InvokedClosureSatisfiesTypeInput > ;
38503849
38513850/** Gets the type of `ce` when viewed as an implementation of `FnOnce`. */
38523851private Type invokedClosureFnTypeAt ( InvokedClosureExpr ce , TypePath path ) {
3853- InvokedClosureSatisfiesConstraint :: satisfiesConstraintType ( ce , _, path , result )
3852+ InvokedClosureSatisfiesType :: satisfiesConstraintType ( ce , _, path , result )
38543853}
38553854
38563855/**
0 commit comments