aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/selection.go
AgeCommit message (Collapse)Author
2021-03-04cmd/compile: remove types2.(*Selection).TArgs(), now that instance bug seems ↵Dan Scales
fixed Previously, we would sometimes see an internal (*instance) type for a receiver of a types2 method, which was a bug. To deal with that, we put in an extra (*Selection).TArgs() method. However, that (*instance) type is no longer showing up for receivers, so we can remove the types2 method we added and do the work with existing types2 API methods. Change-Id: I03e68f5bbaaf82fe706b6efecbb02e951bbd3cd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/298869 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
2021-03-03cmd/compile/internal/types2: use correct recv for parameterized embedded methodsRobert Griesemer
Methods of generic types are instantiated lazily (upon use). Thus, when we encounter a method of such a type, we need to instantiate the method signature with the receiver type arguments. We infer those type arguments from the method receiver. If the method is embedded, we must use the actual embedded receiver type, otherwise the receiver type declared with the method doesn't match up and inference will fail. (Note that there's no type inference in the source code here, it's only the implementation which uses the existing inference mechanism to easily identify the actual type arguments. If the implementation is correct, the inference will always succeed.) Updates #44688. Change-Id: Ie35b62bebaeaf42037f2ca00cf8bd34fec2ddd9c Reviewed-on: https://go-review.googlesource.com/c/go/+/298129 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-18[dev.typeparams] cmd/compile: use new converter functions rather than ↵Robert Griesemer
methods (fix build) Change-Id: I4dcaca1f2e67ee32f70c22b2efa586232ca519bb Reviewed-on: https://go-review.googlesource.com/c/go/+/293958 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-02-18[dev.typeparams] cmd/compile: support generic types (with stenciling of ↵Dan Scales
method calls) A type may now have a type param in it, either because it has been composed from a function type param, or it has been declared as or derived from a reference to a generic type. No objects or types with type params can be exported yet. No generic type has a runtime descriptor (but will likely eventually be associated with a dictionary). types.Type now has an RParam field, which for a Named type can specify the type params (in order) that must be supplied to fully instantiate the type. Also, there is a new flag HasTParam to indicate if there is a type param (TTYPEPARAM) anywhere in the type. An instantiated generic type (whether fully instantiated or re-instantiated to new type params) is a defined type, even though there was no explicit declaration. This allows us to handle recursive instantiated types (and improves printing of types). To avoid the need to transform later in the compiler, an instantiation of a method of a generic type is immediately represented as a function with the method as the first argument. Added 5 tests on generic types to test/typeparams, including list.go, which tests recursive generic types. Change-Id: Ib7ff27abd369a06d1c8ea84edc6ca1fd74bbb7c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/292652 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
2020-10-27[dev.typeparams] cmd/compile/internal/types: review of selection.goRobert Griesemer
Except for the package name, this file is unchanged from the go/types version. f=selection.go; diff $f ../../../../go/types/$f 7c7 < package types2 --- > package types Change-Id: I09c26a744f445ec992c554d293e3ca9896b5c849 Reviewed-on: https://go-review.googlesource.com/c/go/+/265698 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-10-21[dev.typeparams] cmd/compile/internal/importer, types2: initial check-in of ↵Robert Griesemer
types2 and importer This is a copy of the importer and types2 (unreviewed) prototype version excluding the testdata directory containing tests (see below). Each file is marked with the comment // UNREVIEWED on the first line. The plan is to check in this code wholesale (it runs and passes all tests) and then review the code file-by-file via subsequent CLs and remove the "// UNREVIEWED" comments as we review the files. Since most tests are unchanged from the original go/types, the next CL will commit those tests as they don't need to be reviewed again. (Eventually we may want to factor them out and share them from a single place, e.g. the test directory.) The existing file fmtmap_test.go was updated. Change-Id: I9bd0ad1a7e7188b501423483a44d18e623c0fe71 Reviewed-on: https://go-review.googlesource.com/c/go/+/263624 Trust: Robert Griesemer <gri@golang.org> Trust: Keith Randall <khr@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>