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>
It was already not possible to implement an interface that was or
embedded the predeclared interface "comparable" in ordinary (non-
constraint) use, but trying to do so would lead to confusing errors
(missing method "==").
Simply disallow the use of such interfaces outside constraints,
as we do for interfaces containing type lists.
Change-Id: I15ccf1b77226a50baf16df46192e90144208f9dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/238300
Reviewed-by: Robert Griesemer <gri@golang.org>
It turns out that defaultImporter has modifiable fields, so making it a
package scope variable can cause confusion in the use by test/run.go.
Change-Id: I33b060f2ffd17639312e7aa15a632268a3c14ab1
Reviewed-on: https://go-review.googlesource.com/c/go/+/238299
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Since we have to recompute the underlying type of each type in a
type list after instantiation (if any), there is no need to restrict
the types in the type list anymore.
Per the adjustment in the design draft.
Change-Id: I51ced90788e06ed4a9dbd34566e3baca7f3afe20
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/771574
Reviewed-by: Robert Griesemer <gri@google.com>
The underlying type of each type list entry must be computed
(again) _after_ the interface was instantiated because its
original typelist may have contained type parameters that were
substituted with defined types.
Passes all.bash.
Change-Id: I65a234fe6b9bc7b36121532410a0ecc29061516e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/770445
Reviewed-by: Robert Griesemer <gri@google.com>
- fix endless recursion when caused by trace output for self-referential generic types
- print pointer designation of type parameters in type parameter lists
Change-Id: I02d985187ee5e42fdaece2e7420824de8c90a906
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/770152
Reviewed-by: Robert Griesemer <gri@google.com>
If a defined type is passed as an argument for a paramater
of a composite generic but unnamed type (and vice versa),
use the defined type's underlying type for type inference
rather than fail.
Passes all.bash.
Change-Id: I90b33b549c1d0e7569c1520b0f8e45a67152df43
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/770149
Reviewed-by: Robert Griesemer <gri@google.com>
types.Identical will report that two instantiated types are different
even if they are instantiated with the same type arguments.
Change our comparison so that we treat them as the same.
This lets us drop fully resolving all types, which is good because
that wasn't correct anyhow.
Change-Id: Ibcf2dc08896ecacb11ca302627e5d0c6f0722da7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/769080
Reviewed-by: Ian Lance Taylor <iant@google.com>
There are still a couple of issues with pointer type parameters
that have constraints containing type lists, but at least as far
as method constraints are concerned the code is now matching the
design.
Passes all.bash.
Change-Id: I7b7ad9e03bc6ed159dca2343d3fa6a04fc188659
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/765805
Reviewed-by: Robert Griesemer <gri@google.com>