Skip to content

go/types: Info.Selections records unique objects for generic methods #51184

@dominikh

Description

@dominikh

Consider https://gotipplay.golang.org/p/DBMZ9zBIaGB

We have a generic and a normal method named Bar, which result in the following two objects in Info.Defs:

def: Bar = func (pkg.Generic[T]).Bar() [0xc0000699a0]
def: Bar = func (pkg.Normal).Bar() [0xc000069b30]

All calls to Normal.Bar map to the same object in Info.Selections, which is also the object that was recorded in Info.Defs:

use: &{recv Bar} = func (pkg.Normal).Bar() [0xc000069b30]
use: &{recv Bar} = func (pkg.Normal).Bar() [0xc000069b30]
use: &{recv Bar} = func (pkg.Normal).Bar() [0xc000069b30]

However, each call to Generic[T].Bar maps to a different object, none of which matches one in Info.Defs:

use: &{recv Bar} = func (pkg.Generic[T]).Bar() [0xc00013e280]
use: &{recv Bar} = func (pkg.Generic[T]).Bar() [0xc00013e370]
use: &{recv Bar} = func (pkg.Generic[T]).Bar() [0xc00013e460]

(The same behavior can be observed with Info.Uses instead of Info.Selections.)

Is this expected behavior?

/cc @findleyr

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions