@@ -205,6 +205,13 @@ private module Input2 implements InputSig2 {
205205 constraint = object .getTrait ( )
206206 )
207207 }
208+
209+ private predicate testConditionSatisfiesConstraint (
210+ TypeAbstraction abs , TypeMention condition , TypeMention constraint
211+ ) {
212+ conditionSatisfiesConstraint ( abs , condition , constraint ) and
213+ constraint .resolveType ( ) .( TraitType ) .getTrait ( ) .getName ( ) .getText ( ) = "TryFuture"
214+ }
208215}
209216
210217private module M2 = Make2< Input2 > ;
@@ -1725,6 +1732,31 @@ private module BlanketImplementation {
17251732 not exists ( impl .getAttributeMacroExpansion ( ) )
17261733 }
17271734
1735+ predicate isBlanketImplementation ( Impl impl ) { exists ( getBlanketImplementationTypeParam ( impl ) ) }
1736+
1737+ predicate duplicatedImpl ( Impl impl1 , Impl impl2 ) {
1738+ isBlanketImplementation ( impl1 ) and
1739+ isBlanketImplementation ( impl2 ) and
1740+ impl1 != impl2 and
1741+ getBlanketImplementationTypeParam ( impl1 ) .toString ( ) =
1742+ getBlanketImplementationTypeParam ( impl2 ) .toString ( ) and
1743+ impl1 .getTrait ( ) .toString ( ) = impl2 .getTrait ( ) .toString ( ) and
1744+ impl1 .getLocation ( ) .getFile ( ) != impl2 .getLocation ( ) .getFile ( ) and
1745+ impl1 .getLocation ( ) .getFile ( ) .getBaseName ( ) = impl2 .getLocation ( ) .getFile ( ) .getBaseName ( )
1746+ }
1747+
1748+ Impl getCanonicalImpl ( Impl impl ) {
1749+ isBlanketImplementation ( impl ) and
1750+ result =
1751+ max ( Impl impl0 |
1752+ duplicatedImpl ( impl , impl0 ) or impl = impl0
1753+ |
1754+ impl0 order by impl0 .getLocation ( ) .getFile ( ) .getAbsolutePath ( )
1755+ )
1756+ }
1757+
1758+ predicate isCanonicalBlanketImplementation ( Impl impl ) { impl = getCanonicalImpl ( impl ) }
1759+
17281760 /**
17291761 * Holds if `impl` is a blanket implementation for a type parameter and the type
17301762 * parameter must implement `trait`.
@@ -1760,6 +1792,7 @@ private module BlanketImplementation {
17601792 private predicate blanketImplementationMethod (
17611793 Impl impl , Trait trait , string name , int arity , Function f
17621794 ) {
1795+ isCanonicalBlanketImplementation ( impl ) and
17631796 f = impl .( ImplItemNode ) .getASuccessor ( name ) and
17641797 blanketImplementationTraitBound ( impl , trait ) and
17651798 f .getParamList ( ) .hasSelfParam ( ) and
@@ -1780,11 +1813,15 @@ private module BlanketImplementation {
17801813 predicate relevantConstraint ( MethodCall mc , Type constraint ) {
17811814 methodCallMatchesBlanketImpl ( mc , _, _, constraint .( TraitType ) .getTrait ( ) , _)
17821815 }
1816+
1817+ predicate useUniversalConditions ( ) { none ( ) }
17831818 }
17841819
17851820 predicate debugSatisfiesConstraintType ( MethodCall mc , Trait trait , TypePath path , Type ty ) {
17861821 SatisfiesConstraint< MethodCall , SatisfiesConstraintInput > :: satisfiesConstraintType ( mc ,
1787- TTrait ( trait ) , path , ty )
1822+ TTrait ( trait ) , path , ty ) and
1823+ // 521 results
1824+ trait .getName ( ) .getText ( ) = "TryFuture"
17881825 }
17891826
17901827 predicate getBlanketImpl ( MethodCall mc , Type t , Impl impl , Trait trait , Function f ) {
@@ -1834,8 +1871,8 @@ private Function resolveMethodCallTarget(MethodCall mc) {
18341871 // The method comes from an `impl` block targeting the type of the receiver.
18351872 result = getMethodFromImpl ( mc )
18361873 or
1837- result = BlanketImplementation:: getMethodFromBlanketImpl ( mc )
1838- or
1874+ // result = BlanketImplementation::getMethodFromBlanketImpl(mc)
1875+ // or
18391876 // The type of the receiver is a type parameter and the method comes from a
18401877 // trait bound on the type parameter.
18411878 result = getTypeParameterMethod ( mc .getTypeAt ( TypePath:: nil ( ) ) , mc .getMethodName ( ) )
0 commit comments