This can happen due to earlier errors. This change avoids the panic
but reports a follow-up error. Not ideal, but good enough for now.
Fixes#40056.
Change-Id: I500d4fc2b058cdc70f28883ff8d004df4b43fe4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/241130
Reviewed-by: Robert Griesemer <gri@golang.org>
Also, take type lists into account when computing predicate.
Addresses crash #27 of #39634.
Updates #39634.
Change-Id: Id6e1d0d86ac1cb9d79828a3b5fdfbeba0e6aace0
Reviewed-on: https://go-review.googlesource.com/c/go/+/240902
Reviewed-by: Robert Griesemer <gri@golang.org>
Addresses crash #20 of #39634.
Added test, also for some of the other cases that don't crash
anymore.
Updates #39634.
Change-Id: I999e376985a443ac435f64a7c249f891e7b7a6d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/240901
Reviewed-by: Robert Griesemer <gri@golang.org>
HasTypeList existed before but now is also written such that it doesn't
expect an interface to be complete.
Change-Id: I43e8d652c6be755473b201a64bf41d363214881c
Reviewed-on: https://go-review.googlesource.com/c/go/+/240719
Reviewed-by: Robert Griesemer <gri@golang.org>
If an embedded field is an instantiated type, we need to instantiate
it when instantiating the whole type, in case the type arguments
themselves need instantiation.
Fixes#39953
Change-Id: I80b57456aa4f8e8b2eff82359066c37a9c2a40f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
…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>