From 6ea17aa52c5f66c1fd72b74c36f8036e17ddde34 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
-A defined type is always different from any other type. +A named type is always different from any other type. Otherwise, two types are identical if their underlying type literals are structurally equivalent; that is, they have the same literal structure and corresponding components have identical types. In detail: @@ -1775,15 +1775,17 @@ components have identical types. In detail: identical, and either both functions are variadic or neither is. Parameter and result names are not required to match. -
@@ -1798,18 +1800,18 @@ type ( A3 = int A4 = func(A3, float64) *A0 A5 = func(x int, _ float64) *[]string -) -type ( B0 A0 B1 []string B2 struct{ a, b int } B3 struct{ a, c int } B4 func(int, float64) *B0 B5 func(x int, y float64) *A1 -) -type C0 = B0 + C0 = B0 + D0[P1, P2 any] struct{ x P1; y P2 } + E0 = D0[int, string] +)
@@ -1823,6 +1825,7 @@ A3 and int
A4, func(int, float64) *[]string, and A5
B0 and C0
+D0[int, string] and E0
[]int and []int
struct{ a, b *T5 } and struct{ a, b *T5 }
func(x int, y float64) *[]string, func(int, float64) (result *[]string), and A5
@@ -1832,7 +1835,13 @@ func(x int, y float64) *[]string, func(int, float64) (result *[]string), and A5
B0
and B1
are different because they are new types
created by distinct type definitions;
func(int, float64) *B0
and func(x int, y float64) *[]string
-are different because B0
is different from []string
.
+are different because B0
is different from []string
;
+and P1
and P2
are different because they are different
+type parameters.
+D0[int, string]
and struct{ x int; y string }
are
+different because the former is an instantiated
+defined type while the latter is a type literal
+(but they are still assignable).