]> Cypherpunks repositories - gostls13.git/commitdiff
spec: receiver types in method expressions can be parenthesized
authorRobert Griesemer <gri@golang.org>
Thu, 6 Dec 2012 17:31:42 +0000 (09:31 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 6 Dec 2012 17:31:42 +0000 (09:31 -0800)
Fixes #4457.

R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6862046

doc/go_spec.html

index f58c3232168ff7b307caed00346fbb45a2d36af2..d72460da8e0c315379674a1a50c3e9182a3f7c0b 100644 (file)
@@ -3316,7 +3316,7 @@ argument that is the receiver of the method.
 
 <pre class="ebnf">
 MethodExpr    = ReceiverType "." MethodName .
-ReceiverType  = TypeName | "(" "*" TypeName ")" .
+ReceiverType  = TypeName | "(" "*" TypeName ")" | "(" ReceiverType ")" .
 </pre>
 
 <p>
@@ -3353,13 +3353,15 @@ func(tv T, a int) int
 
 <p>
 That function may be called normally with an explicit receiver, so
-these three invocations are equivalent:
+these five invocations are equivalent:
 </p>
 
 <pre>
 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)
 </pre>
 
 <p>