@@ -2215,20 +2215,25 @@ private module BlanketImplementation {
2215
2215
)
2216
2216
}
2217
2217
2218
+ /**
2219
+ * Holds if `impl` is a relevant blanket implementation that requires the
2220
+ * trait `trait` and provides `f`, a method with name `name` and arity
2221
+ * `arity`.
2222
+ */
2218
2223
private predicate blanketImplementationMethod (
2219
- Impl impl , Trait trait , string name , int arity , Function f
2224
+ ImplItemNode impl , Trait trait , string name , int arity , Function f
2220
2225
) {
2221
2226
isCanonicalBlanketImplementation ( impl ) and
2222
2227
blanketImplementationTraitBound ( impl , trait ) and
2223
2228
f .getParamList ( ) .hasSelfParam ( ) and
2224
2229
arity = f .getParamList ( ) .getNumberOfParams ( ) and
2225
2230
(
2226
- f = impl .( ImplItemNode ) . getAssocItem ( name )
2231
+ f = impl .getAssocItem ( name )
2227
2232
or
2228
2233
// If the the trait has a method with a default implementation, then that
2229
2234
// target is interesting as well.
2230
- not exists ( impl .( ImplItemNode ) . getAssocItem ( name ) ) and
2231
- f = impl .( ImplItemNode ) . resolveTraitTy ( ) .getAssocItem ( name )
2235
+ not exists ( impl .getAssocItem ( name ) ) and
2236
+ f = impl .resolveTraitTy ( ) .getAssocItem ( name )
2232
2237
) and
2233
2238
// If the method is already available through one of the trait bounds on the
2234
2239
// type parameter (because they share a common trait ancestor) then ignore
@@ -2248,10 +2253,22 @@ private module BlanketImplementation {
2248
2253
)
2249
2254
}
2250
2255
2256
+ private predicate relevantTraitVisible ( Element mc , Trait trait ) {
2257
+ exists ( ImplItemNode impl |
2258
+ methodCallMatchesBlanketImpl ( mc , _, impl , _, _) and
2259
+ trait = impl .resolveTraitTy ( )
2260
+ )
2261
+ }
2262
+
2251
2263
module SatisfiesConstraintInput implements SatisfiesConstraintInputSig< MethodCall > {
2252
2264
pragma [ nomagic]
2253
2265
predicate relevantConstraint ( MethodCall mc , Type constraint ) {
2254
- methodCallMatchesBlanketImpl ( mc , _, _, constraint .( TraitType ) .getTrait ( ) , _)
2266
+ exists ( Trait trait , Trait trait2 , ImplItemNode impl |
2267
+ methodCallMatchesBlanketImpl ( mc , _, impl , trait , _) and
2268
+ TraitIsVisible< relevantTraitVisible / 2 > :: traitIsVisible ( mc , pragma [ only_bind_into ] ( trait2 ) ) and
2269
+ trait2 = pragma [ only_bind_into ] ( impl .resolveTraitTy ( ) ) and
2270
+ trait = constraint .( TraitType ) .getTrait ( )
2271
+ )
2255
2272
}
2256
2273
2257
2274
predicate useUniversalConditions ( ) { none ( ) }
0 commit comments