Skip to content

Commit fe14d6e

Browse files
design: type parameters: clarify depth of embedded type constraint methods
For golang/go#43621 Change-Id: Ice63bffb753a1c429ee3537cb3093f2903d499d6 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/283113 Trust: Ian Lance Taylor <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 061d70b commit fe14d6e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

design/go2draft-type-parameters.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Ian Lance Taylor\
44
Robert Griesemer\
5-
November 25, 2020
5+
January 11, 2021
66

77
## Abstract
88

@@ -3832,6 +3832,11 @@ func (l *Lockable[T]) Set(v T) {
38323832
When a generic type is a struct, and the type parameter is embedded as
38333833
a field in the struct, any methods of the type parameter's constraint
38343834
are promoted to be methods of the struct.
3835+
(For purposes of [selector
3836+
resolution](https://golang.org/ref/spec#Selectors), these methods are
3837+
treated as being at depth 0 of the type parameter, even if in the
3838+
actual type argument the methods were themselves promoted from an
3839+
embedded type.)
38353840

38363841
```
38373842
// NamedInt is an int with a name. The name can be any type with

0 commit comments

Comments
 (0)