@@ -1430,11 +1430,19 @@ private module MethodResolution {
14301430 * Holds if the method inside `i` with matching name and arity can be ruled
14311431 * out as a target of this call, because the candidate receiver type represented
14321432 * by `derefChain` and `borrow` is incompatible with the `self` parameter type.
1433+ *
1434+ * The types are incompatible because they disagree on a concrete type somewhere
1435+ * inside `root`.
14331436 */
14341437 pragma [ nomagic]
1435- private predicate hasIncompatibleTarget ( ImplOrTraitItemNode i , string derefChain , boolean borrow ) {
1436- ReceiverIsInstantiationOfSelfParam:: argIsNotInstantiationOf ( MkMethodCallCand ( this , derefChain ,
1437- borrow ) , i , _)
1438+ private predicate hasIncompatibleTarget (
1439+ ImplOrTraitItemNode i , string derefChain , boolean borrow , Type root
1440+ ) {
1441+ exists ( TypePath path |
1442+ ReceiverIsInstantiationOfSelfParam:: argIsNotInstantiationOf ( MkMethodCallCand ( this ,
1443+ derefChain , borrow ) , i , _, path ) and
1444+ path .isCons ( root .getATypeParameter ( ) , _)
1445+ )
14381446 }
14391447
14401448 /**
@@ -1448,7 +1456,7 @@ private module MethodResolution {
14481456 ImplItemNode impl , string derefChain , boolean borrow
14491457 ) {
14501458 ReceiverIsNotInstantiationOfBlanketLikeSelfParam:: argIsNotInstantiationOf ( MkMethodCallCand ( this ,
1451- derefChain , borrow ) , impl , _)
1459+ derefChain , borrow ) , impl , _, _ )
14521460 or
14531461 ReceiverSatisfiesBlanketLikeConstraint:: dissatisfiesBlanketConstraint ( MkMethodCallCand ( this ,
14541462 derefChain , borrow ) , impl )
@@ -1479,7 +1487,7 @@ private module MethodResolution {
14791487 forall ( ImplOrTraitItemNode i |
14801488 methodCallNonBlanketCandidate ( this , _, i , _, strippedTypePath , strippedType )
14811489 |
1482- this .hasIncompatibleTarget ( i , derefChain , borrow )
1490+ this .hasIncompatibleTarget ( i , derefChain , borrow , strippedType )
14831491 )
14841492 }
14851493
@@ -1818,7 +1826,7 @@ private module MethodResolution {
18181826 */
18191827 pragma [ nomagic]
18201828 private predicate hasIncompatibleInherentTarget ( Impl impl ) {
1821- ReceiverIsNotInstantiationOfInherentSelfParam:: argIsNotInstantiationOf ( this , impl , _)
1829+ ReceiverIsNotInstantiationOfInherentSelfParam:: argIsNotInstantiationOf ( this , impl , _, _ )
18221830 }
18231831
18241832 /**
0 commit comments