From 787adb6eb3cbb7a8d07700739f008f0b250be55f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 4 Jun 2012 14:24:10 -0700 Subject: [PATCH] go spec: clarify promotion rules for methods/fields of anonymous fields Fixes #3635. R=rsc, r, iant, kevlar, iant CC=golang-dev https://golang.org/cl/6217045 --- doc/go_spec.html | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 78197351f2..90acc1704e 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -684,6 +684,8 @@ consists of all methods with receiver type T. The method set of the corresponding pointer type *T is the set of all methods with receiver *T or T (that is, it also contains the method set of T). +Further rules apply to structs containing anonymous fields, as described +in the section on struct types. Any other type has an empty method set. In a method set, each method must have a unique method name. @@ -955,28 +957,39 @@ struct {

-Fields and methods (§Method declarations) of an anonymous field are -promoted to be ordinary fields and methods of the struct (§Selectors). -The following rules apply for a struct type S and -a type named T: +A field or method f of an +anonymous field in a struct x is called promoted if +x.f is a legal selector that denotes +that field or method f.

-