@@ -126,37 +126,50 @@ private predicate functionResolutionDependsOnArgument0(
126126
127127/**
128128 * Holds if resolving the function `f` in `impl` requires inspecting the type
129- * of applied _arguments_ at position `pos` (including the return type) in
130- * order to determine whether it is the correct resolution.
129+ * of applied _arguments_ at position `pos` (possibly including the return type)
130+ * in order to determine whether it is the correct resolution.
131131 */
132132pragma [ nomagic]
133133predicate functionResolutionDependsOnArgument (
134134 ImplItemNode impl , Function f , TypeParameter traitTp , FunctionPosition pos , TypePath path ,
135135 Type type
136136) {
137137 exists ( string functionName |
138- functionResolutionDependsOnArgument0 ( impl , f , functionName , traitTp , pos , path , type )
138+ functionResolutionDependsOnArgument0 ( impl , f , functionName , traitTp , pos , path , type ) and
139+ not pos .isSelf ( )
139140 |
140- pos .isPosition ( )
141- or
142- // Only disambiguate based on return type when all other positions are trivially
143- // satisfied for all arguments.
144- pos .isReturn ( ) and
145- forall ( FunctionPosition pos0 , TypePath path0 , Type type0 |
146- pos0 .isPosition ( ) and
147- functionResolutionDependsOnArgument0 ( impl , f , _, _, pos0 , path0 , type0 )
141+ exists ( FunctionPosition pos0 |
142+ functionResolutionDependsOnArgument0 ( impl , f , functionName , traitTp , pos0 , _, _)
148143 |
149- type0 . ( TypeParamTypeParameter ) . getTypeParam ( ) = any ( TypeParam tp | not tp . hasTypeBound ( ) )
144+ pos0 . isPosition ( )
150145 or
151- forall ( ImplItemNode impl1 , Function f1 , Type type1 |
152- implSiblings ( _, impl , impl1 ) and
153- f1 = impl1 .getASuccessor ( functionName ) and
154- type1 = getAssocFunctionTypeAt ( f1 , impl1 , pos0 , path0 )
155- |
156- type1 .( TypeParamTypeParameter ) .getTypeParam ( ) = any ( TypeParam tp | not tp .hasTypeBound ( ) )
157- or
158- type0 = type1
146+ pos0 .isReturn ( ) and
147+ not exists ( FunctionPosition pos1 |
148+ functionResolutionDependsOnArgument0 ( impl , f , functionName , _, pos1 , _, _) and
149+ pos1 .isPosition ( )
159150 )
160151 )
152+ // |
153+ // pos.isPosition()
154+ // or
155+ // // Only disambiguate based on return type when all other positions are trivially
156+ // // satisfied for all arguments.
157+ // pos.isReturn() and
158+ // forall(FunctionPosition pos0, TypePath path0, Type type0 |
159+ // pos0.isPosition() and
160+ // functionResolutionDependsOnArgument0(impl, f, _, _, pos0, path0, type0)
161+ // |
162+ // type0.(TypeParamTypeParameter).getTypeParam() = any(TypeParam tp | not tp.hasTypeBound())
163+ // or
164+ // forall(ImplItemNode impl1, Function f1, Type type1 |
165+ // implSiblings(_, impl, impl1) and
166+ // f1 = impl1.getASuccessor(functionName) and
167+ // type1 = getAssocFunctionTypeAt(f1, impl1, pos0, path0)
168+ // |
169+ // type1.(TypeParamTypeParameter).getTypeParam() = any(TypeParam tp | not tp.hasTypeBound())
170+ // or
171+ // type0 = type1
172+ // )
173+ // )
161174 )
162175}
0 commit comments