From e3b48af57560e730a512d79f9d338aafac61f944 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 17 Nov 2021 18:56:46 -0500 Subject: [PATCH] go/types: remove a review comment in implicitTypeAndValue This is a clean port of CL 363440 from types2 to go/types. Change-Id: Ibbef41b5b599d5c88f7122670ab87aa5be512c0a Reviewed-on: https://go-review.googlesource.com/c/go/+/364894 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- src/go/types/expr.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 84eb59d1d0..0a3fa72c97 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -681,16 +681,14 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const return nil, nil, _InvalidUntypedConversion } case *TypeParam: - // TODO(gri) review this code - doesn't look quite right assert(!tparamIsIface) - ok := u.underIs(func(t Type) bool { - if t == nil { + if !u.underIs(func(u Type) bool { + if u == nil { return false } - target, _, _ := check.implicitTypeAndValue(x, t) - return target != nil - }) - if !ok { + t, _, _ := check.implicitTypeAndValue(x, u) + return t != nil + }) { return nil, nil, _InvalidUntypedConversion } // keep nil untyped (was bug #39755) @@ -699,15 +697,13 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const } case *Interface: if tparamIsIface && isTypeParam(target) { - // TODO(gri) review this code - doesn't look quite right - ok := u.typeSet().underIs(func(t Type) bool { - if t == nil { + if !u.typeSet().underIs(func(u Type) bool { + if u == nil { return false } - target, _, _ := check.implicitTypeAndValue(x, t) - return target != nil - }) - if !ok { + t, _, _ := check.implicitTypeAndValue(x, u) + return t != nil + }) { return nil, nil, _InvalidUntypedConversion } // keep nil untyped (was bug #39755) -- 2.50.0