b67443459a
The spec says that an embedded field must be specified as a type name (or a pointer to a type name). This is explicit in the prose and the FieldDecl syntax. However, the prose on promoted methods required a named type (originally the term used for a "defined type"). Before the introduction of alias types, type names could only refer to named/defined types, so the prose was ok. With the introduction of alias types in Go 1.9, we distinguished between defined types (i.e., types given a name through a type declaration) and type aliases (types given an alternative name), and retired the notion of a named type since any type with a name (alias type and defined type) could be considered a "named type". To make things worse, with Go 1.18 we re-introduced the notion of a named type which now includes predeclared types, defined types, type parameters (and with that type aliases denoting named types). In the process some of the wording on method promotion didn't get updated correctly. At attempt to fix this was made with CL 406054, but while that CL's description correctly explained the intent, the CL changed the prose from "defined type" to "named type" (which had the new meaning after Go 1.18), and thus did not fix the issue. This CL fixes that fix by using the term "type name". This makes the prose consistent for embedded types and in turn clarifies that methods of embedded alias types (defined or not) can be promoted, consistent with the implementation. While at it, also document that the type of an embedded field cannot be a type parameter. This restriction has been in place since the introduction of type parameters with Go 1.18 and is enforced by the compiler. Fixes #66540. For #41687. Change-Id: If9e6a03d7b84d24a3e6a5ceda1d46bda99bdf1f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/603958 Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Axel Wagner <axel.wagner.hh@googlemail.com> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
go.env | ||
LICENSE | ||
PATENTS | ||
README.md | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.