diff options
author | Dan Scales <danscales@google.com> | 2021-07-06 10:53:00 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-07-07 17:31:57 +0000 |
commit | b4844c9f54eb6a559d8dc9333cf5b1e66dab8167 (patch) | |
tree | c14c3561c5ccc3542d9b53b3761229b271aa887b /test/typeparam | |
parent | 4676c3675e85a8a82a1513ef1f5e38aebc80ddc8 (diff) | |
download | go-b4844c9f54eb6a559d8dc9333cf5b1e66dab8167.tar.gz go-b4844c9f54eb6a559d8dc9333cf5b1e66dab8167.zip |
[dev.typeparams] cmd/compile: handle the (*T).M method expression with dictionaries
The (*T).M method expression is where M is a value method, but the type
(*T) is a pointer to the main type. In this case, after following any
embedded fields, we need to add an extra star operator when using the
receiver arg in the closure call.
Thanks to Cuong for finding/pointing out an example for this case
(typeparam/mdempsky/14.go) This example also shows that we now need the
ability to export/import OEFACE and OIDATA, which I added.
Change-Id: Ida0f81ce757fff78fec6276c60052ed71d207454
Reviewed-on: https://go-review.googlesource.com/c/go/+/333014
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'test/typeparam')
-rw-r--r-- | test/typeparam/dictionaryCapture.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/typeparam/dictionaryCapture.go b/test/typeparam/dictionaryCapture.go index af508859e1..26af7a09b0 100644 --- a/test/typeparam/dictionaryCapture.go +++ b/test/typeparam/dictionaryCapture.go @@ -73,20 +73,32 @@ func methodExpressions() { x := s[int]{a:7} f0 := s[int].g0 f0(x) + f0p := (*s[int]).g0 + f0p(&x) f1 := s[int].g1 is7(f1(x)) + f1p := (*s[int]).g1 + is7(f1p(&x)) f2 := s[int].g2 is77(f2(x)) + f2p := (*s[int]).g2 + is77(f2p(&x)) } func genMethodExpressions[T comparable](want T) { x := s[T]{a: want} f0 := s[T].g0 f0(x) + f0p := (*s[T]).g0 + f0p(&x) f1 := s[T].g1 if got := f1(x); got != want { panic(fmt.Sprintf("f1(x) == %d, want %d", got, want)) } + f1p := (*s[T]).g1 + if got := f1p(&x); got != want { + panic(fmt.Sprintf("f1p(&x) == %d, want %d", got, want)) + } f2 := s[T].g2 if got1, got2 := f2(x); got1 != want || got2 != want { panic(fmt.Sprintf("f2(x) == %d, %d, want %d, %d", got1, got2, want, want)) |