@@ -1946,48 +1946,14 @@ func populateTypeParamParents(tw *trap.Writer, typeparams *types.TypeParamList,
19461946// some changes to the object to avoid returning objects relating to instantiated
19471947// types.
19481948func getObjectBeingUsed (tw * trap.Writer , ident * ast.Ident ) types.Object {
1949- obj := tw .Package .TypesInfo .Uses [ident ]
1950- if obj == nil {
1951- return nil
1952- }
1953- if override , ok := tw .ObjectsOverride [obj ]; ok {
1954- return override
1955- }
1956- if funcObj , ok := obj .(* types.Func ); ok {
1957- sig := funcObj .Type ().(* types.Signature )
1958- if recv := sig .Recv (); recv != nil {
1959- recvType := recv .Type ()
1960- originType , isSame := tryGetGenericType (recvType )
1961-
1962- if originType == nil {
1963- if pointerType , ok := recvType .(* types.Pointer ); ok {
1964- originType , isSame = tryGetGenericType (pointerType .Elem ())
1965- }
1966- }
1967-
1968- if originType == nil || isSame {
1969- return obj
1970- }
1971-
1972- for i := 0 ; i < originType .NumMethods (); i ++ {
1973- meth := originType .Method (i )
1974- if meth .Name () == funcObj .Name () {
1975- return meth
1976- }
1977- }
1978- if interfaceType , ok := originType .Underlying ().(* types.Interface ); ok {
1979- for i := 0 ; i < interfaceType .NumMethods (); i ++ {
1980- meth := interfaceType .Method (i )
1981- if meth .Name () == funcObj .Name () {
1982- return meth
1983- }
1984- }
1985- }
1986- log .Fatalf ("Could not find method %s on type %s" , funcObj .Name (), originType )
1987- }
1949+ switch obj := tw .Package .TypesInfo .Uses [ident ].(type ) {
1950+ case * types.Var :
1951+ return obj .Origin ()
1952+ case * types.Func :
1953+ return obj .Origin ()
1954+ default :
1955+ return obj
19881956 }
1989-
1990- return obj
19911957}
19921958
19931959// tryGetGenericType returns the generic type of `tp`, and a boolean indicating
0 commit comments