From bb3e2117777a2d9438bab0ab9e386e22662aa499 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
Date: Tue, 16 Oct 2018 16:50:25 -0700
Subject: [PATCH] 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
Reviewed-by: Rob Pike
Reviewed-by: Matthew Dempsky
---
doc/go_spec.html | 14 +++++++-------
1 file 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 @@
@@ -2202,11 +2202,11 @@ Receiver = Parameters .
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 T
or *T
(possibly using
-parentheses) where T
is a type name. The type denoted by T
is called
-the receiver base type; it must not be a pointer or interface type and
-it must be defined in the same package as the method.
-The method is said to be bound to the base type and the method name
+Its type must be a defined type T
or a
+pointer to a defined type T
. T
is called the receiver
+base type. 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 bound to its receiver base type and the method name
is visible only within selectors for type T
or *T
.
@@ -2226,7 +2226,7 @@ the non-blank method and field names must be distinct.
-Given type Point
, the declarations
+Given defined type Point
, the declarations
--
2.50.0