1
0
mirror of https://github.com/golang/go synced 2024-11-13 12:30:21 -07:00
The Go programming language
Go to file
Robert Griesemer b67443459a spec: clarify prose for embedded struct fields
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>
2024-08-12 18:45:57 +00:00
.github .github: update language change proposal template 2024-08-08 19:02:29 +00:00
api crypto/tls: expose extensions presented by client to GetCertificate 2024-08-09 18:45:11 +00:00
doc spec: clarify prose for embedded struct fields 2024-08-12 18:45:57 +00:00
lib/time lib/time: use consistent directory in mkzip usage message 2024-03-04 17:32:07 +00:00
misc syscall,misc/wasm: fix path expansion on non-unix platforms 2024-08-09 21:22:25 +00:00
src os: employ sendfile(2) for file-to-file copying on SunOS when needed 2024-08-12 18:44:38 +00:00
test go/types, types2: only use fileVersion if 1.21 or greater 2024-08-12 18:42:12 +00:00
.gitattributes
.gitignore runtime,internal: move runtime/internal/sys to internal/runtime/sys 2024-07-23 19:05:35 +00:00
codereview.cfg
CONTRIBUTING.md
go.env cmd/go: additional doc-inspired tests and bug fixes 2023-06-06 19:18:46 +00:00
LICENSE LICENSE: update per Google Legal 2024-08-09 14:54:31 +00:00
PATENTS
README.md README: fix CC BY license name 2024-07-22 17:45:27 +00:00
SECURITY.md SECURITY.md: update the Reporting a Vulnerability link 2023-09-22 21:17:24 +00:00

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image 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.