diff options
author | Robert Findley <rfindley@google.com> | 2022-02-04 00:17:22 -0500 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2022-02-08 16:50:25 +0000 |
commit | caecc2b0acff200e25a90fb86af9373e5829da1c (patch) | |
tree | 44ef0c7d8625c89a43cf06a807804efdbe80d499 /internal/typeparams/typeparams_go117.go | |
parent | 164402db9dd6fa703883e516c61a536114a42198 (diff) | |
download | golang-x-tools-caecc2b0acff200e25a90fb86af9373e5829da1c.tar.gz |
internal/typeparams: add a generic form of types.AssignableTo
For some use-cases, it is helpful to compute predicates between
uninstantiated generic types.
This CL implements one such predicate for types.AssignableTo, a helper
GenericAssignableTo which reports if, for generic types V and T with the
same number of type parameters, all instantiations V[A_1, ..., A_N] are
assignable to the corresponding instantiation T[A_1, ..., A_N].
For #50887
For #50447
Change-Id: I7a0550fba05666bb2375d478d5390a123e09f556
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383094
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'internal/typeparams/typeparams_go117.go')
-rw-r--r-- | internal/typeparams/typeparams_go117.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/typeparams/typeparams_go117.go b/internal/typeparams/typeparams_go117.go index 5fd3fc351..b4788978f 100644 --- a/internal/typeparams/typeparams_go117.go +++ b/internal/typeparams/typeparams_go117.go @@ -185,6 +185,11 @@ func GetInstances(info *types.Info) map[*ast.Ident]Instance { return nil } // this Go version. type Context struct{} +// NewContext returns a placeholder Context instance. +func NewContext() *Context { + return &Context{} +} + // Instantiate is unsupported on this Go version, and panics. func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) { unsupported() |