You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: design/47916-parameterized-go-types.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -61,29 +61,29 @@ Type parameters are considered identical (as reported by the `Identical` functio
61
61
### Type parameter and type argument lists
62
62
63
63
```go
64
-
type TParamList struct { /* ... */ }
64
+
type TypeParamList struct { /* ... */ }
65
65
66
-
func(*TParamList) Len() int
67
-
func (*TParamList) At(i int) *TypeParam
66
+
func(*TypeParamList) Len() int
67
+
func (*TypeParamList) At(i int) *TypeParam
68
68
69
69
type TypeList struct { /* ... */ }
70
70
71
71
func(*TypeList) Len() int
72
72
func (*TypeList) At(i int) Type
73
73
```
74
74
75
-
A `TParamList` type is added to represent lists of type parameters. Similarly, a `TypeList` type is added to represent lists of type arguments. Both types have a `Len` and `At` methods, with the only difference between them being the type returned by `At`.
75
+
A `TypeParamList` type is added to represent lists of type parameters. Similarly, a `TypeList` type is added to represent lists of type arguments. Both types have a `Len` and `At` methods, with the only difference between them being the type returned by `At`.
76
76
77
77
### Changes to `types.Named`
78
78
79
79
```go
80
-
func (*Named) TParams() *TParamList
81
-
func (*Named) SetTParams([]*TypeParam)
80
+
func (*Named) TypeParams() *TypeParamList
81
+
func (*Named) SetTypeParams([]*TypeParam)
82
82
func (*Named) TArgs() *TypeList
83
83
func (*Named) Orig() *Named
84
84
```
85
85
86
-
The `TParams` and `SetTParams` methods are added to `*Named` to get and set type parameters. Once a type parameter has been passed to `SetTParams`, it is considered _bound_ and must not be used in any subsequent calls to `Named.SetTParams` or `Signature.SetTParams`; doing so will panic. For non-parameterized types, `TParams` returns nil.
86
+
The `TypeParams` and `SetTypeParams` methods are added to `*Named` to get and set type parameters. Once a type parameter has been passed to `SetTypeParams`, it is considered _bound_ and must not be used in any subsequent calls to `Named.SetTypeParams` or `Signature.SetTypeParams`; doing so will panic. For non-parameterized types, `TypeParams` returns nil.
87
87
88
88
When a `*Named` type is instantiated (see [instantiation](#instantiation) below), the result is another `*Named` type which retains the original type parameters but gains type arguments. These type arguments are substituted in the underlying type of the original type to produce a new underlying type. Similarly, type arguments are substituted for the corresponding receiver type parameter in method declarations to produce a new method type.
89
89
@@ -110,16 +110,16 @@ Parameterized named types continue to be considered identical (as reported by th
110
110
### Changes to `types.Signature`
111
111
112
112
```go
113
-
func (*Signature) TParams() *TParamList
114
-
func (*Signature) SetTParams([]*TypeParam)
113
+
func (*Signature) TypeParams() *TypeParamList
114
+
func (*Signature) SetTypeParams([]*TypeParam)
115
115
116
-
func (*Signature) RParams() *TParamList
116
+
func (*Signature) RParams() *TypeParamList
117
117
func (*Signature) SetRParams([]*TypeParam)
118
118
```
119
119
120
-
The `TParams` and `SetTParams` methods are added to `*Signature` to get and set type parameters. As described in the section on `*Named` types, passing a type parameter more than once to either `Named.SetTParams` or `Signature.SetTParams` will panic.
120
+
The `TypeParams` and `SetTypeParams` methods are added to `*Signature` to get and set type parameters. As described in the section on `*Named` types, passing a type parameter more than once to either `Named.SetTypeParams` or `Signature.SetTypeParams` will panic.
121
121
122
-
The `RParams` and `SetRParams` methods allow getting and setting receiver type parameters. Signatures cannot have both type parameters and receiver type parameters. For a given receiver `t`, once `t.SetTParams` has been called with a non-empty slice, calling `t.SetRParams` with a non-empty slice will panic, and vice-versa.
122
+
The `RParams` and `SetRParams` methods allow getting and setting receiver type parameters. Signatures cannot have both type parameters and receiver type parameters. For a given receiver `t`, once `t.SetTypeParams` has been called with a non-empty slice, calling `t.SetRParams` with a non-empty slice will panic, and vice-versa.
123
123
124
124
For `Signatures` to be identical (as reported by `Identical`), they must be identical ignoring type parameters, have the same number of type parameters, and have pairwise identical type parameter constraints.
0 commit comments