Skip to content

Commit

Permalink
design: 47916-parameterized-go-types.md: fix the signature of Constraint
Browse files Browse the repository at this point in the history
Constraint returns a Type, not an *Interface.

Change-Id: I1707773f3924e5d3503f026f6508bfb132d66c99
Reviewed-on: https://go-review.googlesource.com/c/proposal/+/344672
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
findleyr committed Aug 24, 2021
1 parent 30cea26 commit 18a0d33
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions design/47916-parameterized-go-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The sections below describe new types and functions to be added, as well as how
```go
func NewTypeParam(obj *TypeName, constraint Type) *TypeParam

func (*TypeParam) Constraint() *Interface
func (*TypeParam) Constraint() Type
func (*TypeParam) SetConstraint(Type)
func (*TypeParam) Obj() *TypeName

Expand All @@ -44,7 +44,7 @@ func (*TypeParam) Underlying() Type
func (*TypeParam) String() string
```

Within type and function declarations, type parameters names denote type parameter types, represented by the new `TypeParam` type. It is a `Type` with two additional methods: `Constraint`, which returns its type constraint, and `SetConstraint` which may be used to set its type constraint. The `SetConstraint` method is necessary to break cycles in situations where the constraint type references the type parameter itself.
Within type and function declarations, type parameters names denote type parameter types, represented by the new `TypeParam` type. It is a `Type` with two additional methods: `Constraint`, which returns its type constraint (which may be a `*Named` or `*Interface`), and `SetConstraint` which may be used to set its type constraint. The `SetConstraint` method is necessary to break cycles in situations where the constraint type references the type parameter itself.

For a `*TypeParam`, `Underlying` is the identity method, and `String` returns its name.

Expand Down

0 comments on commit 18a0d33

Please sign in to comment.