@@ -1946,71 +1946,6 @@ 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- obj1 := getObjectBeingUsed1 (tw , ident )
1950- obj2 := getObjectBeingUsed2 (tw , ident )
1951- if obj1 != obj2 {
1952- string1 := "nil"
1953- if obj1 != nil {
1954- string1 = obj1 .String ()
1955- }
1956- string2 := "nil"
1957- if obj1 != nil {
1958- string2 = obj1 .String ()
1959- }
1960- log .Fatalf ("different results!\n obj1 = %s\n obj2 = %s\n " , string1 , string2 )
1961- }
1962- return obj2
1963- }
1964-
1965- // getobjectBeingUsed looks up `ident` in `tw.Package.TypesInfo.Uses` and makes
1966- // some changes to the object to avoid returning objects relating to instantiated
1967- // types.
1968- func getObjectBeingUsed1 (tw * trap.Writer , ident * ast.Ident ) types.Object {
1969- obj := tw .Package .TypesInfo .Uses [ident ]
1970- if obj == nil {
1971- return nil
1972- }
1973- if override , ok := tw .ObjectsOverride [obj ]; ok {
1974- return override
1975- }
1976- if funcObj , ok := obj .(* types.Func ); ok {
1977- sig := funcObj .Type ().(* types.Signature )
1978- if recv := sig .Recv (); recv != nil {
1979- recvType := recv .Type ()
1980- originType , isSame := tryGetGenericType (recvType )
1981-
1982- if originType == nil {
1983- if pointerType , ok := recvType .(* types.Pointer ); ok {
1984- originType , isSame = tryGetGenericType (pointerType .Elem ())
1985- }
1986- }
1987-
1988- if originType == nil || isSame {
1989- return obj
1990- }
1991-
1992- for i := 0 ; i < originType .NumMethods (); i ++ {
1993- meth := originType .Method (i )
1994- if meth .Name () == funcObj .Name () {
1995- return meth
1996- }
1997- }
1998- if interfaceType , ok := originType .Underlying ().(* types.Interface ); ok {
1999- for i := 0 ; i < interfaceType .NumMethods (); i ++ {
2000- meth := interfaceType .Method (i )
2001- if meth .Name () == funcObj .Name () {
2002- return meth
2003- }
2004- }
2005- }
2006- log .Fatalf ("Could not find method %s on type %s" , funcObj .Name (), originType )
2007- }
2008- }
2009-
2010- return obj
2011- }
2012-
2013- func getObjectBeingUsed2 (tw * trap.Writer , ident * ast.Ident ) types.Object {
20141949 switch obj := tw .Package .TypesInfo .Uses [ident ].(type ) {
20151950 case * types.Var :
20161951 return obj .Origin ()
0 commit comments