cmd/compile: reflected methods have extra wrapping #33641
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?1.12.7
Does this issue reproduce with the latest release?
Probably.
What operating system and processor architecture are you using (
go env
)?amd64, or amd64p32. Reproduces on playground, probably not specific to it.
What did you do?
https://play.golang.org/p/tEu9qKfYdEB
Obtain a method using (reflect.Value).MethodByName(), convert it to a function type, and call it.
The method has a stack trace.
What did you expect to see?
A function pointer identical to one I could call directly.
What did you see instead?
A fancy wrapped function pointer which is doing some kind of marshalling and then unmarshalling of its parameters.
(The stray "callFn" is an attempt to ensure that the compiler isn't just outsmarting me here by taking short-cuts when it can easily see that the method it's calling is a method of a local object...)
It seems to me like it would be really nice if there were a way for the methods reflect.MethodByName yields to be the same functions that you get from method values.
The text was updated successfully, but these errors were encountered: