]> Cypherpunks.ru repositories - gostls13.git/commit
reflect: derive correct Value method in panic messages
authorJoe Tsai <joetsai@digital-static.net>
Mon, 18 Apr 2022 17:05:24 +0000 (10:05 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 4 May 2022 00:51:08 +0000 (00:51 +0000)
commit8b389eb2be2d66563669c74f6515b5f537542ce9
tree5b147df0759d8497e51bdfb6a8f99b8e76cbe595
parent64b6e44ad7e4db4525b7f05be128bc7d8713afb8
reflect: derive correct Value method in panic messages

methodName was brittle in that it assumed exactly where
in the call stack the exported Value method is.
This broke since recent inlining optimizations changed
exactly which frame the exported method was located.
Instead, iterate through a sufficient number of stack entries
and dynamically determined the exported Value method name.

This is more maintainable, but slightly slower.
The slowdown is acceptable since panics are not the common case.

Change-Id: I9fc939627007d7bae004b4969516ad44be09c270
Reviewed-on: https://go-review.googlesource.com/c/go/+/403494
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
src/reflect/all_test.go
src/reflect/value.go