From cd5f2cf50f6372e31dde0b407c1c3be57a2ce90f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 3 Dec 2021 12:20:33 -0800 Subject: [PATCH] doc/go1.18: add documentation for changes to go/types The number of involved CLs is too large (hundreds) so no CLs are mentioned in (html) comments. Updates #47694 Change-Id: I655d800a1e56a71e9d70a190f1c42c17baf6861e Reviewed-on: https://go-review.googlesource.com/c/go/+/369099 Trust: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Gopher Robot Reviewed-by: Robert Findley --- doc/go1.18.html | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index c2a04ef419..fb0b054e28 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -451,6 +451,93 @@ Do not send CLs removing the interior tags from such phrases. +
go/types
+
+

+ Per the proposal + + Additions to go/types to support type parameters + + the following additions are made to the go/types package: +

+
    +
  • + The new type + TypeParam, factory function + NewTypeParam, + and associated methods were added to represent a type parameter. +
  • +
  • + The new type + TypeParamList holds a list of + type parameters. +
  • +
  • + The new type + TypeList and factory function + NewTypeList facilitate storing + a list of types. +
  • +
  • + The new factory function + NewSignatureType allocates a + Signature with + (receiver or function) type parameters. + To access those type parameters, the Signature type has two new methods + Signature.RecvTypeParams and + Signature.TypeParams. +
  • +
  • + Named types have four new methods: + Named.Origin to get the original + parameterized types of instantiated types, + Named.TypeArgs and + Named.TypeParams to get the + type arguments or type parameters of an instantiated or parameterized type, and + Named.SetTypeParams to set the + type parameters (for instance, when importing a named type where allocation of the named + type and setting of type parameters cannot be done both at once due to possible cycles). +
  • +
  • + The Interface type has four new methods: + Interface.IsComparable and + Interface.IsMethodSet to + query properties of the type set defined by the interface, and + Interface.MarkImplicit and + Interface.IsImplicit to set + and test whether the interface is an implicit interface around a type constraint literal. +
  • +
  • + The new types + Union and + Term, factory functions + NewUnion and + NewTerm, and associated + methods were added to represent type sets in interfaces. +
  • +
  • + The new function + Instantiate + instantiates a parameterized type. +
  • +
  • + The new Info.Instances + map records function and type instantiations through the new + Instance type. +
  • +
  • + The new type ArgumentError + and associated methods were added to represent an error related to a type argument. +
  • +
  • + The new type Context and factory function + NewContext + were added to facilitate sharing of identical type instances across type-checked packages. +
  • +
+
+
+
image/draw

-- 2.50.0