]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: fix noder.Addr() to not call typechecker
authorDan Scales <danscales@google.com>
Thu, 11 Mar 2021 01:27:30 +0000 (17:27 -0800)
committerDan Scales <danscales@google.com>
Fri, 12 Mar 2021 02:30:33 +0000 (02:30 +0000)
commite87c4bb3ef9d1f0aee3c9cc9fec8bef7fcadd6d8
tree76cff111a81f0d20e311cce87f2bee892e446737
parent71330963c080960f2f398fcd711a1fa14f68d503
cmd/compile:  fix noder.Addr() to not call typechecker

Simple change to avoid calling the old typechecker in noder.Addr(). This
fixes cases where generic code calls a pointer method with a non-pointer
receiver.

Added test typeparam/lockable.go that now works with this change.

For lockable.go to work, also fix incorrect check to decide whether to
translate an OXDOT now or later. We should delay translating an OXDOT
until instantiation (because we don't know how embedding, etc. will
work) if the receiver has any typeparam, not just if the receiver type
is a simple typeparam. We also have to handle OXDOT for now in
IsAddressable(), until we can remove calls to the old typechecker in
(*irgen).funcBody().

Change-Id: I77ee5efcef9a8f6c7133564106a32437e36ba4bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/300990
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/noder/expr.go
src/cmd/compile/internal/noder/helpers.go
test/typeparam/lockable.go [new file with mode: 0644]