Skip to content

Commit

Permalink
[dev.go2go] go/types: the underlying type of a type parameter is itself
Browse files Browse the repository at this point in the history
No need to call Under() when we know that we have a type parameter.

While at it: Turn off debug mode.

Change-Id: Ia0b39d88191c8e5ac580e7e84a512061911c40cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/239162
Reviewed-by: Robert Griesemer <[email protected]>
  • Loading branch information
griesemer committed Jun 20, 2020
1 parent cbdb93d commit c0c872e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/go/types/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// debugging/development support
const debug = true // leave on during development
const debug = false // leave on during development

// If forceStrict is set, the type-checker enforces additional
// rules not specified by the Go 1 spec, but which will
Expand Down
24 changes: 12 additions & 12 deletions src/go/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,17 +836,17 @@ func optype(typ Type) Type {
}

// Converter methods
func (t *TypeParam) Basic() *Basic { return optype(t.Under()).Basic() }
func (t *TypeParam) Array() *Array { return optype(t.Under()).Array() }
func (t *TypeParam) Slice() *Slice { return optype(t.Under()).Slice() }
func (t *TypeParam) Struct() *Struct { return optype(t.Under()).Struct() }
func (t *TypeParam) Pointer() *Pointer { return optype(t.Under()).Pointer() }
func (t *TypeParam) Tuple() *Tuple { return optype(t.Under()).Tuple() }
func (t *TypeParam) Signature() *Signature { return optype(t.Under()).Signature() }
func (t *TypeParam) Sum() *Sum { return optype(t.Under()).Sum() }
func (t *TypeParam) Interface() *Interface { return optype(t.Under()).Interface() }
func (t *TypeParam) Map() *Map { return optype(t.Under()).Map() }
func (t *TypeParam) Chan() *Chan { return optype(t.Under()).Chan() }
func (t *TypeParam) Basic() *Basic { return optype(t).Basic() }
func (t *TypeParam) Array() *Array { return optype(t).Array() }
func (t *TypeParam) Slice() *Slice { return optype(t).Slice() }
func (t *TypeParam) Struct() *Struct { return optype(t).Struct() }
func (t *TypeParam) Pointer() *Pointer { return optype(t).Pointer() }
func (t *TypeParam) Tuple() *Tuple { return optype(t).Tuple() }
func (t *TypeParam) Signature() *Signature { return optype(t).Signature() }
func (t *TypeParam) Sum() *Sum { return optype(t).Sum() }
func (t *TypeParam) Interface() *Interface { return optype(t).Interface() }
func (t *TypeParam) Map() *Map { return optype(t).Map() }
func (t *TypeParam) Chan() *Chan { return optype(t).Chan() }

// func (t *TypeParam) Named() *Named // named types are not permitted in type lists
// func (t *TypeParam) TypeParam() *TypeParam // declared below
Expand Down Expand Up @@ -966,7 +966,7 @@ func (t *Interface) Underlying() Type { return t }
func (t *Map) Underlying() Type { return t }
func (t *Chan) Underlying() Type { return t }
func (t *Named) Underlying() Type { return t.underlying }
func (t *TypeParam) Underlying() Type { return t.Under() }
func (t *TypeParam) Underlying() Type { return t }
func (t *instance) Underlying() Type { return t }
func (t *bottom) Underlying() Type { return t }
func (t *top) Underlying() Type { return t }
Expand Down

0 comments on commit c0c872e

Please sign in to comment.