21b4e0146a
The unifier was written such that it was possible to specify a different set of type parameters (declared by different generic declarations) for each type x, y being unified, to allow for what is called "bidirectional unification" in the documentation (comments). However, in the current implementation, this mechanism is not used: - For function type inference, we only consider the type parameter list of the generic function (type parameters that appear in the arguments are considered stand-alone types). We use type parameter renaming to avoid any problems in case of recursive generic calls that rely on type inference. - For constraint type inference, the type parameters for the types x and y (i.e., the type parameter and its constraint) are the same and had to be explicitly set to be identical. This CL removes the ability to set separate type parameter lists. Instead a single type parameter list is used during unification and is provided when we initialize a unifier. As a consequence, we don't need to maintain the separate tparamsList data structure: since we have a single list of type parameters we can keep it directly in the unifier. Adjust all the unifier code accordingly and update comments. As an aside, remove the `exact` flag from the unifier as it was never set. However, keep the functionality for now and use a constant (exactUnification) instead. This makes it easy to find the respectice code without incurring any cost. Change-Id: I969ba6dbbed2d65d06ba4e20b97bdc362c806772 Reviewed-on: https://go-review.googlesource.com/c/go/+/463223 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> |
||
---|---|---|
.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 Attributions 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.