1
0
mirror of https://github.com/golang/go synced 2024-11-14 20:00:31 -07:00

go/types, types2: simplify Default function

Change-Id: Ie2b7c1324ec7947c6ff43187dda99b83bcb64f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/581775
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Robert Griesemer 2024-04-25 08:57:36 -07:00 committed by Robert Griesemer
parent 8c0da423f7
commit 06478e4b46
2 changed files with 6 additions and 2 deletions

View File

@ -518,7 +518,9 @@ func identicalInstance(xorig Type, xargs []Type, yorig Type, yargs []Type) bool
// it returns the incoming type for all other types. The default type
// for untyped nil is untyped nil.
func Default(t Type) Type {
if t, ok := Unalias(t).(*Basic); ok {
// Alias and named types cannot denote untyped types
// so there's no need to call Unalias or under, below.
if t, _ := t.(*Basic); t != nil {
switch t.kind {
case UntypedBool:
return Typ[Bool]

View File

@ -521,7 +521,9 @@ func identicalInstance(xorig Type, xargs []Type, yorig Type, yargs []Type) bool
// it returns the incoming type for all other types. The default type
// for untyped nil is untyped nil.
func Default(t Type) Type {
if t, ok := Unalias(t).(*Basic); ok {
// Alias and named types cannot denote untyped types
// so there's no need to call Unalias or under, below.
if t, _ := t.(*Basic); t != nil {
switch t.kind {
case UntypedBool:
return Typ[Bool]