// 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
// 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
}
}
}
- 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
// 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.
// 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)