aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-01-26 13:20:34 -0800
committerGopher Robot <gobot@golang.org>2023-01-27 14:33:39 +0000
commit21b4e0146a40a95687c4d3e36939eef991f03c1e (patch)
tree0fa2c398ac41e1a66c169415900d743e833aea68 /src/encoding
parent178080740c1bc33f2c7f164504eedc24210bbf1e (diff)
downloadgo-21b4e0146a40a95687c4d3e36939eef991f03c1e.tar.xz
go/types, types2: simplify unifier
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>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions