]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove a review comment in implicitTypeAndValue
authorRobert Findley <rfindley@google.com>
Wed, 17 Nov 2021 23:56:46 +0000 (18:56 -0500)
committerRobert Findley <rfindley@google.com>
Thu, 18 Nov 2021 02:10:22 +0000 (02:10 +0000)
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 <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/expr.go

index 84eb59d1d09fe33b06ce0653f8b9600410c2c920..0a3fa72c970db5866184d1c2bd06a780a6e5537b 100644 (file)
@@ -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)