…ere’s more than one generic constraint.
Check of first constraint was breaking the loop, so other constraints was skipped
Fixes#39754.
Change-Id: I48caa380472371a438c2d2029d1383d03dbf22df
GitHub-Last-Rev: bf418db782
GitHub-Pull-Request: golang/go#39902
Reviewed-on: https://go-review.googlesource.com/c/go/+/240339
Reviewed-by: Robert Griesemer <gri@golang.org>
We were relying on calling typeString and treating that as an AST ident,
with special handling for instantiated types, but that fails if there is
an instantiated type within a type literal.
Fixes#39881
Change-Id: I793fe359868d8d73e830aa8dc67cf52de99355a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/240197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
It has no package, so we need to check for Pkg() == nil.
Fixes#39878
Change-Id: I14a47c5098f97ce42dfa8cc875819f244a2b0201
Reviewed-on: https://go-review.googlesource.com/c/go/+/240013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
No test case because we will don't have a general test harness.
Fixes#39851
Change-Id: If7b1262404f390eba80d53c2c1d40724252a5833
Reviewed-on: https://go-review.googlesource.com/c/go/+/240004
Reviewed-by: Ian Lance Taylor <iant@golang.org>
No test because the test harness doesn't support test packages.
(But probably we'll need a better test harness.)
Fixes#39839
Change-Id: I4532b1443dbdd081552ffb78477cbe5039183416
Reviewed-on: https://go-review.googlesource.com/c/go/+/239708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
No test because it doesn't really fit into the current test harness.
FIxes#39797
Change-Id: I410217a0e6b3af6808a111d0edbafaa3047b12f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/239707
Reviewed-by: Ian Lance Taylor <iant@golang.org>
If an instantiated function from a different package uses a plain
identifier to instantiate a generic type or function, include the
package name in the generated identifier.
Fixes#39834
Change-Id: I4c786bac8972475e180cb41178520439343a36ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/239706
Reviewed-by: Ian Lance Taylor <iant@golang.org>
A very small change because the `--help` flag printing nothing was bugging me.
Change-Id: I221c657ba055e94db7a574c8e8fd044bb135f8b1
GitHub-Last-Rev: 8781a1a29f
GitHub-Pull-Request: golang/go#39788
Reviewed-on: https://go-review.googlesource.com/c/go/+/239537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The go/types package doesn't give us an easy way to get the type,
so just reject it.
Fixes#39743
Change-Id: I5404c10baede0fd2cf67980b06fbebd214a50dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/239382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
types.TypeString defaults to using the package path for references to names.
Provide our own types.Qualifier that uses just the package name,
since that is what the translated code has to use.
Fixes#39744
Change-Id: Icde289b2ed0fdd9b0a9aae6aae4557a8951d25a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/239381
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ignore struct tags when generating an instantiated names, and when
comparing types for identity.
Fixes#39737
Change-Id: I53e67fa1d09214dafc4088a59eb00e1a6f18ef3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/239379
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Also: Don't convert an untyped nil to a type parameter when
checking if an untyped value (nil) can be coverted to a target
type.
Fixes#39755.
Change-Id: Ib2645759dc659b9c80c2d0a457180eb9616c7cb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/239338
Reviewed-by: Robert Griesemer <gri@golang.org>
Move tracking of instantiations from translator to Importer,
so that we can track all instantiations within a package
to avoid duplicates.
Fixes#39749
Change-Id: If6cd5bcdc6e19c2d6481e62a6187ddf7f4fac72a
Reviewed-on: https://go-review.googlesource.com/c/go/+/239337
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Type lists can contain defined types, make sure we use their
underlying types when computing operational types.
Change-Id: I8b6b11302f6b28977916e495f1486cc7b352e859
Reviewed-on: https://go-review.googlesource.com/c/go/+/239163
Reviewed-by: Robert Griesemer <gri@golang.org>
No need to call Under() when we know that we have a type parameter.
While at it: Turn off debug mode.
Change-Id: Ia0b39d88191c8e5ac580e7e84a512061911c40cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/239162
Reviewed-by: Robert Griesemer <gri@golang.org>
In particular, it cannot be a type parameter
with an operational type that is an interface.
Fixes#39723.
Change-Id: Ia6b65eaecd472dd71b1c9f7631ce1872f06e5a6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/239161
Reviewed-by: Robert Griesemer <gri@golang.org>
No test because the test framework doesn't easily support
package paths containing a dot.
Fixes#39722
Change-Id: If43dc768b28f521d10bd2ef4288aa789aa4bee01
Reviewed-on: https://go-review.googlesource.com/c/go/+/239160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
It's not correct to do it here, as we aren't instantiating this
particular type.
Also had a loop check to avoid endless instantiating a recursive type.
Fixes#39688
Change-Id: Ief4c57bb5cea3013501e33ab5bc82a29707af5be
Reviewed-on: https://go-review.googlesource.com/c/go/+/239137
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The operational type for a type parameter T constrained by
interface { type T } is the top type, not itself. The latter
can lead to infinite recursions.
Fix suggested by @tdakkota.
Fixes#39680.
Change-Id: I8a6a6c503f09294b9276965f1d9e05c5d22ec912
Reviewed-on: https://go-review.googlesource.com/c/go/+/238863
Reviewed-by: Robert Griesemer <gri@golang.org>
Previously we instantiated the underlying type, so we didn't need this.
We stopped doing that to get the same type in the generated code,
but now we need to get the right type arguments, rather than just
leaving the type parameters there.
Fixes#39692
Change-Id: I56ba8ff017c37219e7cb9bb6e07a4beb8c50e9dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/238797
Reviewed-by: Ian Lance Taylor <iant@golang.org>
If enabled in types.Config, the type checker can handle generic
methods (methods that have their own type parameter list).
This CL fixes an issue with method lookup (missing method test)
that caused some assignments to fail.
Note that this does not affect the go2go tool - we don't have any
plans to support such generic methods. Type-checking them is
fairly straight-forward. Translating them into code is not.
Change-Id: I8b8a6b814417277c728732bd5a9421c99440a47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/238627
Reviewed-by: Robert Griesemer <gri@golang.org>
It shows up when instantiating with types with a package path
containing a slash, as in net/url.Error.
Fixes#39642
Change-Id: Icf40e7bcdf1de7c84f58ebde35ebffadbb071d72
Reviewed-on: https://go-review.googlesource.com/c/go/+/238623
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Avoids crashing when we see a universe scope type in an instantiated type.
Change-Id: Iec3ebee291973180a63cd4cddef7e2f131a30053
Reviewed-on: https://go-review.googlesource.com/c/go/+/238622
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Turn an embedded type parameter into a regular field with the type
parameter as the name and the type argument as the type.
Fixes#39671
Change-Id: I0050499b90feb5085cac4452d53fa0dc6f614c48
Reviewed-on: https://go-review.googlesource.com/c/go/+/238621
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Adds a little note about `GO2PATH` and that it is required for the `go2go` tool.
Updates #39617
Change-Id: I9e3cea16a7d7539555180dc065957d6a56f390b9
GitHub-Last-Rev: 2aa6815df7
GitHub-Pull-Request: golang/go#39657
Reviewed-on: https://go-review.googlesource.com/c/go/+/238498
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Add an accessor to go/types: HasTypeList for an interface type.
Fixes#39626
Change-Id: I880eabbe6660739cd7febc1df89eaa7f9262c8c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/238360
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Check for comparable embedded via a different embedded interface.
Check for comparable embedded in a defined interface type.
Change-Id: I8c9c576ad31443dcb77b4be71e29ab2284339cb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/238357
Reviewed-by: Ian Lance Taylor <iant@golang.org>