]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: minor refactoring of missingMethod following CL 494615
authorRob Findley <rfindley@google.com>
Fri, 12 May 2023 15:31:28 +0000 (11:31 -0400)
committerRobert Findley <rfindley@google.com>
Fri, 12 May 2023 15:47:10 +0000 (15:47 +0000)
Make the refactoring suggested by gri@ in that CL.

Change-Id: I6c363f3ba5aaa3c616d3982d998b989de7046a86
Reviewed-on: https://go-review.googlesource.com/c/go/+/494617
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/types2/lookup.go
src/go/types/lookup.go

index ccf724373b75428e5167beae5fd9ec17bb1bda0b..b7370ca38d01231044208661c1c90767c89f1087 100644 (file)
@@ -387,10 +387,6 @@ func (check *Checker) missingMethod(V, T Type, static bool, equivalent func(x, y
                                        obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
                                        f, _ = obj.(*Func)
                                        if f != nil {
-                                               // This method is formatted in funcString below, so must be type-checked.
-                                               if check != nil {
-                                                       check.objDecl(f, nil)
-                                               }
                                                state = wrongName
                                        }
                                }
@@ -421,6 +417,13 @@ func (check *Checker) missingMethod(V, T Type, static bool, equivalent func(x, y
        }
 
        if cause != nil {
+               if f != nil {
+                       // This method may be formatted in funcString below, so must have a fully
+                       // set up signature.
+                       if check != nil {
+                               check.objDecl(f, nil)
+                       }
+               }
                switch state {
                case notFound:
                        switch {
index 0ff5db74e6262cd8a66e90d2c6f927214eab1d58..d96dd86e5eb0d866658ca0e7b7fb521c5507303a 100644 (file)
@@ -389,10 +389,6 @@ func (check *Checker) missingMethod(V, T Type, static bool, equivalent func(x, y
                                        obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
                                        f, _ = obj.(*Func)
                                        if f != nil {
-                                               // This method is formatted in funcString below, so must be type-checked.
-                                               if check != nil {
-                                                       check.objDecl(f, nil)
-                                               }
                                                state = wrongName
                                        }
                                }
@@ -423,6 +419,13 @@ func (check *Checker) missingMethod(V, T Type, static bool, equivalent func(x, y
        }
 
        if cause != nil {
+               if f != nil {
+                       // This method may be formatted in funcString below, so must have a fully
+                       // set up signature.
+                       if check != nil {
+                               check.objDecl(f, nil)
+                       }
+               }
                switch state {
                case notFound:
                        switch {