From: Robert Griesemer
Date: Sat, 8 Jan 2022 02:20:22 +0000 (-0800)
Subject: spec: adjust rules for specific types once more
X-Git-Tag: go1.18beta2~113
X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3df44722013b54790e97a32aff945708bd1b62f7;p=gostls13.git
spec: adjust rules for specific types once more
Introduce a (local) notion of a set of representative types,
which serves as a representation/approximation of an
interface's actual type set. If the set of representative
types is is non-empty and finite, it corresponds to the set
of specific types of the interface.
In the implementation, the set of representative types serves
as a finite representation of an interface's type set, together
with the set of methods.
Change-Id: Ib4c6cd5e17b81197672e4247be9737dd2cb6b56f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376834
Trust: Robert Griesemer
Reviewed-by: Ian Lance Taylor
---
diff --git a/doc/go_spec.html b/doc/go_spec.html
index fa6630719b..7c20236016 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
@@ -1980,30 +1980,34 @@ or in unions of such terms.
-More precisely, for a given interface, the set ð of specific types is defined as follows:
+More precisely, for a given interface, the set of specific types corresponds to
+the set ð
of representative types of the interface, if ð
is non-empty and finite.
+Otherwise, if ð
is empty or infinite, the interface has no specific types.
+
+
+
+For a given interface, type element or type term, the set ð
of representative types is defined as follows:
- - For an interface with no type elements, ð is the empty set.
+
- For an interface with no type elements, ð
is the (infinite) set of all types.
- - For an interface with type elements, ð is the intersection
- of the specific types of its type elements with specific types
- (type elements that have no specific types are ignored).
+
- For an interface with type elements,
+ ð
is the intersection of the representative types of its type elements.
- - For a non-interface type term
T
- or ~T
, ð is the set consisting of the type T
.
+ - For a non-interface type term
T
or a term of the form ~T
,
+ ð
is the set consisting of the type T
.
- For a union of terms
t1|t2|â¦|tn
,
- ð is the union of the specific types of the terms.
+ ð
is the union of the representative types of the terms.
-If ð is empty, the interface has no specific types.
An interface may have specific types even if its type set
is empty.
@@ -2021,8 +2025,10 @@ interface{ int } // int
interface{ ~string } // string
interface{ int|~string } // int, string
interface{ Celsius|Kelvin } // Celsius, Kelvin
+interface{ float64|any } // no specific types (union is all types)
interface{ int; m() } // int (but type set is empty because int has no method m)
-interface{ int; any } // int (any has no specific types and is ignored)
+interface{ ~int; m() } // int (but type set is infinite because many integer types have a method m)
+interface{ int; any } // int
interface{ int; string } // no specific types (intersection is empty)