mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Look through aliases when identifying method receivers
This commit is contained in:
@@ -169,11 +169,12 @@ func (l *Labeler) ScopedObjectID(object types.Object, getTypeLabel func() Label)
|
|||||||
|
|
||||||
// findMethodWithGivenReceiver finds a method with `object` as its receiver, if one exists
|
// findMethodWithGivenReceiver finds a method with `object` as its receiver, if one exists
|
||||||
func findMethodWithGivenReceiver(object types.Object) *types.Func {
|
func findMethodWithGivenReceiver(object types.Object) *types.Func {
|
||||||
meth := findMethodOnTypeWithGivenReceiver(object.Type(), object)
|
unaliasedType := types.Unalias(object.Type())
|
||||||
|
meth := findMethodOnTypeWithGivenReceiver(unaliasedType, object)
|
||||||
if meth != nil {
|
if meth != nil {
|
||||||
return meth
|
return meth
|
||||||
}
|
}
|
||||||
if pointerType, ok := object.Type().(*types.Pointer); ok {
|
if pointerType, ok := unaliasedType.(*types.Pointer); ok {
|
||||||
meth = findMethodOnTypeWithGivenReceiver(pointerType.Elem(), object)
|
meth = findMethodOnTypeWithGivenReceiver(pointerType.Elem(), object)
|
||||||
}
|
}
|
||||||
return meth
|
return meth
|
||||||
|
|||||||
Reference in New Issue
Block a user