@@ -1891,7 +1891,7 @@ private predicate methodCandidate(Type type, string name, int arity, Impl impl)
18911891 */
18921892pragma [ nomagic]
18931893private predicate methodCandidateTrait ( Type type , Trait trait , string name , int arity , Impl impl ) {
1894- trait = resolvePath ( impl .( ImplItemNode ) .getTraitPath ( ) ) and
1894+ trait = impl .( ImplItemNode ) .resolveTraitTy ( ) and
18951895 methodCandidate ( type , name , arity , impl )
18961896}
18971897
@@ -1902,6 +1902,16 @@ private predicate isMethodCall(MethodCall mc, Type rootType, string name, int ar
19021902 arity = mc .getNumberOfArguments ( )
19031903}
19041904
1905+ /** Holds if the trait `trait` is visible at the method call `mc`. */
1906+ bindingset [ mc, trait]
1907+ pragma [ inline_late]
1908+ predicate methodCallTraitIsVisible ( MethodCall mc , TraitItemNode trait ) {
1909+ exists ( ItemNode encl |
1910+ encl .getADescendant * ( ) = mc and
1911+ trait = encl .getASuccessor ( _, _)
1912+ )
1913+ }
1914+
19051915private module IsInstantiationOfInput implements IsInstantiationOfInputSig< MethodCall > {
19061916 pragma [ nomagic]
19071917 predicate potentialInstantiationOf ( MethodCall mc , TypeAbstraction impl , TypeMention constraint ) {
@@ -1912,7 +1922,12 @@ private module IsInstantiationOfInput implements IsInstantiationOfInputSig<Metho
19121922 methodCandidateTrait ( rootType , mc .getTrait ( ) , name , arity , impl )
19131923 or
19141924 not exists ( mc .getTrait ( ) ) and
1915- methodCandidate ( rootType , name , arity , impl )
1925+ methodCandidate ( rootType , name , arity , impl ) and
1926+ (
1927+ methodCallTraitIsVisible ( mc , impl .( ImplItemNode ) .resolveTraitTy ( ) )
1928+ or
1929+ not exists ( impl .( ImplItemNode ) .resolveTraitTy ( ) )
1930+ )
19161931 )
19171932 }
19181933
0 commit comments