From c0c872e8b0c73287d3db07fac3022faa1609c4ea Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 19 Jun 2020 20:55:27 -0700 Subject: [PATCH] [dev.go2go] go/types: the underlying type of a type parameter is itself 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 --- src/go/types/check.go | 2 +- src/go/types/type.go | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/go/types/check.go b/src/go/types/check.go index 284eeddf4f977a..1aee6e8b2e5d20 100644 --- a/src/go/types/check.go +++ b/src/go/types/check.go @@ -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 diff --git a/src/go/types/type.go b/src/go/types/type.go index 16e601184fe20a..fd1777b327eb47 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -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 @@ -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 }