From e06d90136f18fbb1ffa46537d01eb3552f45b0bc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 6 Dec 2012 09:31:42 -0800 Subject: [PATCH] spec: receiver types in method expressions can be parenthesized Fixes #4457. R=rsc, iant, r, ken CC=golang-dev https://golang.org/cl/6862046 --- doc/go_spec.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index f58c323216..d72460da8e 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3316,7 +3316,7 @@ argument that is the receiver of the method.
 MethodExpr    = ReceiverType "." MethodName .
-ReceiverType  = TypeName | "(" "*" TypeName ")" .
+ReceiverType  = TypeName | "(" "*" TypeName ")" | "(" ReceiverType ")" .
 

@@ -3353,13 +3353,15 @@ func(tv T, a int) int

That function may be called normally with an explicit receiver, so -these three invocations are equivalent: +these five invocations are equivalent:

 t.Mv(7)
 T.Mv(t, 7)
-f := T.Mv; f(t, 7)
+(T).Mv(t, t)
+f1 := T.Mv; f1(t, 7)
+f2 := (T).Mv; f2(t, 7)
 

-- 2.48.1