]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/types2: factor out slice elem computation for copy built-in
authorRobert Griesemer <gri@golang.org>
Wed, 20 Oct 2021 22:06:35 +0000 (15:06 -0700)
committerRobert Griesemer <gri@golang.org>
Sat, 23 Oct 2021 16:17:58 +0000 (16:17 +0000)
commit3cd28baffd2c97d53cbc703a8787365e68050466
treea3584c94f3e0896474ca573ba9c08b7397522de1
parentb0f7eb6c0dee68c91d622cc5fcba1074626753b3
cmd/compile/internal/types2: factor out slice elem computation for copy built-in

Implement singleUnder[String] which determines a single underlying type
for a given type: either the underlying type, or the single underlying
type for a type parameter, if it exists. Use singleUnder[String] instead
of optype for copy built-in.

This CL removes a dependency on optype and also makes the copy built-in
slighty more general for generic arguments (the source argument may be
constrained by a slice or string simultaneously).

Change-Id: Ia329e96afc69a09d2ca3b1f82fe712d4f7ba1d9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/357413
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/testdata/check/builtins.go2