Skip to content

reflect: clarify that behaviour of Value returned from Value.Method is different from method value #6581

Description

@stevenblenkinsop
What steps will reproduce the problem?

http://play.golang.org/p/xPA5hW4GQe

What is the expected output?

Some users might expect the receiver of a function value returned by Value.Method to be
evaluated the same way it is for a method value once they've removed in from reflection
land by calling Value.Interface on it.

What do you see instead?

The reflect.Value, rather than the value it represents, is still used to derive the
receiver on each call even after you remove the value from reflection land. This could
be seen as being in keeping with

"The arguments to a Call on the returned function should not include a receiver;
the returned function will always use v as the receiver."

The potentially surprising implications of this could be clarified though, since the
focus of this statement appears to be on the fact that you don't need to provide your
own receiver on each call, rather than on a deviation of the behaviour of the method
from the language feature it approximates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone 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