@@ -991,8 +991,10 @@ private module MethodResolution {
991991 )
992992 }
993993
994+ private module MethodTraitIsVisible = TraitIsVisible< methodCallTraitCandidate / 2 > ;
995+
994996 private predicate methodCallVisibleTraitCandidate ( MethodCall mc , Trait trait ) {
995- TraitIsVisible < methodCallTraitCandidate / 2 > :: traitIsVisible ( mc , trait )
997+ MethodTraitIsVisible :: traitIsVisible ( mc , trait )
996998 }
997999
9981000 bindingset [ mc, impl]
@@ -1820,33 +1822,33 @@ private Type inferMethodCallType(AstNode n, TypePath path) {
18201822 * "calls" to tuple variants and tuple structs.
18211823 */
18221824private module NonMethodResolution {
1823- private import FunctionOverloading
1824-
18251825 /**
1826- * Holds if the associated function `implFunction` implements `traitFunction`,
1827- * which belongs to `trait`, and resolving the function `implFunction` requires
1828- * inspecting the type of applied _arguments_ at position `pos` in order to
1829- * determine whether it is the correct resolution.
1826+ * Holds if the associated function `implFunction` at `impl` implements
1827+ * `traitFunction`, which belongs to `trait`, and resolving the function
1828+ * `implFunction` requires inspecting the type of applied _arguments_ at
1829+ * position `pos` in order to determine whether it is the correct resolution.
18301830 *
18311831 * `type` is the type at `pos` of `implFunction` which mathces a type parameter of
18321832 * `traitFunction` at `pos`.
18331833 */
18341834 pragma [ nomagic]
18351835 private predicate traitFunctionDependsOnArgument (
18361836 TraitItemNode trait , NonMethodFunction traitFunction , FunctionTypePosition pos , Type type ,
1837- NonMethodFunction implFunction
1837+ ImplItemNode impl , NonMethodFunction implFunction
18381838 ) {
18391839 exists ( TypePath path |
1840- functionTypeAtPath ( implFunction , pos , path , type ) and
1840+ functionTypeAtPath ( implFunction , impl , pos , path , type ) and
18411841 implFunction .implements ( traitFunction ) and
1842- traitTypeParameterOccurrence ( trait , traitFunction , _, pos , path , _)
1842+ FunctionOverloading :: traitTypeParameterOccurrence ( trait , traitFunction , _, pos , path , _)
18431843 |
18441844 not pos .isReturn ( )
18451845 or
18461846 // We only check that the context of the call provides relevant type information
18471847 // when no argument can
18481848 not exists ( FunctionTypePosition pos0 |
1849- traitTypeParameterOccurrence ( trait , traitFunction , _, pos0 , _, _) and
1849+ FunctionOverloading:: traitTypeParameterOccurrence ( trait , traitFunction , _, pos0 , _, _) or
1850+ FunctionOverloading:: functionResolutionDependsOnArgument ( impl , implFunction , pos0 , _, _)
1851+ |
18501852 not pos0 .isReturn ( )
18511853 )
18521854 )
@@ -1882,6 +1884,8 @@ private module NonMethodResolution {
18821884 )
18831885 }
18841886
1887+ private module BlanketTraitIsVisible = TraitIsVisible< blanketCallTraitCandidate / 2 > ;
1888+
18851889 private Type getTypeAt ( NonMethodCall fc , FunctionTypePosition pos , TypePath path ) {
18861890 result = inferType ( fc .getNodeAt ( pos ) , path )
18871891 }
@@ -1896,7 +1900,7 @@ private module NonMethodResolution {
18961900 exists ( getTypeAt ( fc , pos , blanketPath ) ) and
18971901 functionInfoBlanketRelevantPos ( f , name , arity , impl , trait , pos , t , blanketPath ,
18981902 blanketTypeParam ) and
1899- TraitIsVisible < blanketCallTraitCandidate / 2 > :: traitIsVisible ( fc , trait )
1903+ BlanketTraitIsVisible :: traitIsVisible ( fc , trait )
19001904 )
19011905 }
19021906
@@ -2022,7 +2026,7 @@ private module NonMethodResolution {
20222026 pragma [ nomagic]
20232027 private NonMethodFunction resolveCallTargetRec ( ) {
20242028 result = this .resolveCallTargetBlanketCand ( _) and
2025- not functionResolutionDependsOnArgument ( _, result , _, _, _)
2029+ not FunctionOverloading :: functionResolutionDependsOnArgument ( _, result , _, _, _)
20262030 or
20272031 NonMethodArgsAreInstantiationsOf:: argsAreInstantiationsOf ( this , _, result )
20282032 }
@@ -2031,7 +2035,7 @@ private module NonMethodResolution {
20312035 ItemNode resolveCallTargetNonRec ( ) {
20322036 not this .( Call ) .hasTrait ( ) and
20332037 result = this .getPathResolutionResolved ( ) and
2034- not functionResolutionDependsOnArgument ( _, result , _, _, _)
2038+ not FunctionOverloading :: functionResolutionDependsOnArgument ( _, result , _, _, _)
20352039 }
20362040
20372041 pragma [ inline]
@@ -2054,12 +2058,13 @@ private module NonMethodResolution {
20542058 |
20552059 FunctionOverloading:: functionResolutionDependsOnArgument ( i , f , pos , _, t0 )
20562060 or
2057- traitFunctionDependsOnArgument ( _, _, pos , t0 , f )
2061+ traitFunctionDependsOnArgument ( _, _, pos , t0 , i , f )
20582062 )
20592063 or
20602064 // match against the trait function itself
20612065 exists ( Trait trait |
2062- traitTypeParameterOccurrence ( trait , f , _, pos , _, TSelfTypeParameter ( trait ) )
2066+ FunctionOverloading:: traitTypeParameterOccurrence ( trait , f , _, pos , _,
2067+ TSelfTypeParameter ( trait ) )
20632068 )
20642069 )
20652070 }
@@ -2072,14 +2077,15 @@ private module NonMethodResolution {
20722077 predicate hasTargetCand ( ImplOrTraitItemNode i , Function f ) {
20732078 f = this .resolveAssocCallTargetCand ( i )
20742079 or
2075- exists ( TraitItemNode trait , NonMethodFunction resolved , Function f1 |
2080+ exists ( TraitItemNode trait , NonMethodFunction resolved , ImplItemNode i1 , Function f1 |
20762081 this .hasTraitResolved ( trait , resolved ) and
2077- traitFunctionDependsOnArgument ( trait , resolved , _, _, f1 ) and
2078- f = i .getASuccessor ( _)
2082+ traitFunctionDependsOnArgument ( trait , resolved , _, _, i1 , f1 )
20792083 |
2080- f = f1
2084+ f = f1 and
2085+ i = i1
20812086 or
2082- f = resolved
2087+ f = resolved and
2088+ i = trait
20832089 )
20842090 }
20852091 }
0 commit comments