]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: unexport Checker.LookupFieldOrMethod
authorRobert Griesemer <gri@golang.org>
Fri, 31 Jan 2020 04:13:02 +0000 (20:13 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 31 Jan 2020 14:46:05 +0000 (14:46 +0000)
Implementation changes in go/types for #6977 required that internal
LookupFieldOrMethod calls had access to the current *Checker. In
order to make quick progress, I added a *Checker receiver to the
function LookupFieldOrMethod (thus making it a method), and added
a new function LookupFieldOrMethod. The plan was always to rename
that function (Checker.LookupFieldOrMethod) such that it wouldn't
be exported; with the obvious name being Checker.lookupFieldOrMethod.
But that name was already in use which is why I postponed the rename.
Eventually I forgot to clean it up. This CL fixes that with the
following renames:

Checker.lookupFieldOrMethod => Checker.rawLookupFieldOrMethod
Checker.LookupFieldOrMethod => Checker.lookupFieldOrMethod

Updates #6977.
Fixes #36916.

Change-Id: Icfafd0de9a19841ba5bd87142730fe7323204491
Reviewed-on: https://go-review.googlesource.com/c/go/+/217134
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
api/go1.14.txt
src/go/types/builtins.go
src/go/types/call.go
src/go/types/lookup.go

index af962ec0abfcfd51cc684365ffcee05359eea298..3af0fee3b4cad97525bc39aafe91350424c59315 100644 (file)
@@ -150,7 +150,6 @@ pkg go/doc, type Example struct, Suffix string
 pkg go/doc, type Func struct, Examples []*Example
 pkg go/doc, type Package struct, Examples []*Example
 pkg go/doc, type Type struct, Examples []*Example
-pkg go/types, method (*Checker) LookupFieldOrMethod(Type, bool, *Package, string) (Object, []int, bool)
 pkg hash/maphash, func MakeSeed() Seed
 pkg hash/maphash, method (*Hash) BlockSize() int
 pkg hash/maphash, method (*Hash) Reset()
index af374b70c6973e980f74e71a721d47a54a71d820..3756303dfbca9327c3b254e398e5777da0fa1d83 100644 (file)
@@ -559,7 +559,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
                base := derefStructPtr(x.typ)
                sel := selx.Sel.Name
-               obj, index, indirect := check.LookupFieldOrMethod(base, false, check.pkg, sel)
+               obj, index, indirect := check.lookupFieldOrMethod(base, false, check.pkg, sel)
                switch obj.(type) {
                case nil:
                        check.invalidArg(x.pos(), "%s has no single field %s", base, sel)
index 31f93726446d417d0404d16d9f64384dd2e2fb58..689ef8744c446e765bed1ec903b430609bd24f52 100644 (file)
@@ -370,7 +370,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                goto Error
        }
 
-       obj, index, indirect = check.LookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel)
+       obj, index, indirect = check.lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel)
        if obj == nil {
                switch {
                case index != nil:
index 648e100060b61e8110d4d5ebcc82678a8cb358d0..342c8baab24f2628662feffc8f8b5f31431abd9c 100644 (file)
@@ -33,19 +33,19 @@ package types
 //     the method's formal receiver base type, nor was the receiver addressable.
 //
 func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
-       return (*Checker)(nil).LookupFieldOrMethod(T, addressable, pkg, name)
+       return (*Checker)(nil).lookupFieldOrMethod(T, addressable, pkg, name)
 }
 
-// Internal use of Checker.LookupFieldOrMethod: If the obj result is a method
+// Internal use of Checker.lookupFieldOrMethod: If the obj result is a method
 // associated with a concrete (non-interface) type, the method's signature
 // may not be fully set up. Call Checker.objDecl(obj, nil) before accessing
 // the method's type.
 // TODO(gri) Now that we provide the *Checker, we can probably remove this
-// caveat by calling Checker.objDecl from LookupFieldOrMethod. Investigate.
+// caveat by calling Checker.objDecl from lookupFieldOrMethod. Investigate.
 
-// LookupFieldOrMethod is like the external version but completes interfaces
+// lookupFieldOrMethod is like the external version but completes interfaces
 // as necessary.
-func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
+func (check *Checker) lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
        // Methods cannot be associated to a named pointer type
        // (spec: "The type denoted by T is called the receiver base type;
        // it must not be a pointer or interface type and it must be declared
@@ -55,7 +55,7 @@ func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package
        // not have found it for T (see also issue 8590).
        if t, _ := T.(*Named); t != nil {
                if p, _ := t.underlying.(*Pointer); p != nil {
-                       obj, index, indirect = check.lookupFieldOrMethod(p, false, pkg, name)
+                       obj, index, indirect = check.rawLookupFieldOrMethod(p, false, pkg, name)
                        if _, ok := obj.(*Func); ok {
                                return nil, nil, false
                        }
@@ -63,7 +63,7 @@ func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package
                }
        }
 
-       return check.lookupFieldOrMethod(T, addressable, pkg, name)
+       return check.rawLookupFieldOrMethod(T, addressable, pkg, name)
 }
 
 // TODO(gri) The named type consolidation and seen maps below must be
@@ -71,8 +71,8 @@ func (check *Checker) LookupFieldOrMethod(T Type, addressable bool, pkg *Package
 //           types always have only one representation (even when imported
 //           indirectly via different packages.)
 
-// lookupFieldOrMethod should only be called by LookupFieldOrMethod and missingMethod.
-func (check *Checker) lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
+// rawLookupFieldOrMethod should only be called by lookupFieldOrMethod and missingMethod.
+func (check *Checker) rawLookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) {
        // WARNING: The code in this function is extremely subtle - do not modify casually!
        //          This function and NewMethodSet should be kept in sync.
 
@@ -297,7 +297,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method *
 
        // A concrete type implements T if it implements all methods of T.
        for _, m := range T.allMethods {
-               obj, _, _ := check.lookupFieldOrMethod(V, false, m.pkg, m.name)
+               obj, _, _ := check.rawLookupFieldOrMethod(V, false, m.pkg, m.name)
 
                // we must have a method (not a field of matching function type)
                f, _ := obj.(*Func)