diff options
author | Robert Griesemer <gri@golang.org> | 2018-10-16 16:50:25 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2018-10-17 20:03:35 +0000 |
commit | bb3e2117777a2d9438bab0ab9e386e22662aa499 (patch) | |
tree | ca845c8a74aef61eeaf8d001a55d3686101a2e04 /doc/go_spec.html | |
parent | dc75744f9c16e6af08f3e4677f28850b874ecc51 (diff) | |
download | go-bb3e2117777a2d9438bab0ab9e386e22662aa499.tar.gz go-bb3e2117777a2d9438bab0ab9e386e22662aa499.zip |
spec: clarify rules for receiver base types
The spec currently provides a syntactic rule for receiver base types,
and a strict reading of those rules prohibits the use of type aliases
referring to pointer types as receiver types.
This strict interpretation breaks an assumed rule for aliases, which
is that a type literal can always be replaced by an alias denoting
that literal.
Furthermore, cmd/compile always accepted this new formulation of the
receiver type rules and so this change will simply validate what has
been implemented all along.
Fixes #27995.
Change-Id: I032289c926a4f070d6f7795431d86635fe64d907
Reviewed-on: https://go-review.googlesource.com/c/142757
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'doc/go_spec.html')
-rw-r--r-- | doc/go_spec.html | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 6c7f2aa902..b8e11e83a4 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ <!--{ "Title": "The Go Programming Language Specification", - "Subtitle": "Version of October 8, 2018", + "Subtitle": "Version of October 17, 2018", "Path": "/ref/spec" }--> @@ -2202,11 +2202,11 @@ Receiver = Parameters . <p> The receiver is specified via an extra parameter section preceding the method name. That parameter section must declare a single non-variadic parameter, the receiver. -Its type must be of the form <code>T</code> or <code>*T</code> (possibly using -parentheses) where <code>T</code> is a type name. The type denoted by <code>T</code> is called -the receiver <i>base type</i>; it must not be a pointer or interface type and -it must be <a href="#Type_definitions">defined</a> in the same package as the method. -The method is said to be <i>bound</i> to the base type and the method name +Its type must be a <a href="#Type_definitions">defined</a> type <code>T</code> or a +pointer to a defined type <code>T</code>. <code>T</code> is called the receiver +<i>base type</i>. A receiver base type cannot be a pointer or interface type and +it must be defined in the same package as the method. +The method is said to be <i>bound</i> to its receiver base type and the method name is visible only within <a href="#Selectors">selectors</a> for type <code>T</code> or <code>*T</code>. </p> @@ -2226,7 +2226,7 @@ the non-blank method and field names must be distinct. </p> <p> -Given type <code>Point</code>, the declarations +Given defined type <code>Point</code>, the declarations </p> <pre> |