From 4ed6317e735af24093b96077d1e813cc8b7dee6a Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Sun, 16 May 2021 14:48:05 -0700 Subject: [dev.typeparams] cmd/compile: always generate (*T).M wrappers for instantiated methods Always generate (*T).M wrappers for instantiated methods, even when the instantiated method is being generated for another package (its source package) Added new function t.IsInstantiated() to check for fully-instantiated types (generic type instantiated with concrete types, hence concrete themselves). This function helps hide the representation of instantiated types outside of the types package. Added new export/import test setsimp.go that needs this change. Change-Id: Ifb700db8c9494e1684c93735edb20f4709be5f7f Reviewed-on: https://go-review.googlesource.com/c/go/+/322193 Trust: Dan Scales Trust: Robert Griesemer Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types/type.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/cmd/compile/internal/types/type.go') diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index e7831121bf..08855f518c 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -279,6 +279,13 @@ func (t *Type) SetRParams(rparams []*Type) { } } +// IsInstantiated reports whether t is a fully instantiated generic type; i.e. an +// instantiated generic type where all type arguments are non-generic or fully +// instantiated generic types. +func (t *Type) IsInstantiated() bool { + return len(t.RParams()) > 0 && !t.HasTParam() +} + // NoPkg is a nil *Pkg value for clarity. // It's intended for use when constructing types that aren't exported // and thus don't need to be associated with any package. -- cgit v1.2.3-54-g00ecf