diff --git a/go/types/objectpath/objectpath_test.go b/go/types/objectpath/objectpath_test.go index 0d67c73a..16b6123b 100644 --- a/go/types/objectpath/objectpath_test.go +++ b/go/types/objectpath/objectpath_test.go @@ -11,6 +11,7 @@ import ( "go/parser" "go/token" "go/types" + "strings" "testing" "golang.org/x/tools/go/buildutil" @@ -279,8 +280,8 @@ var Z map[string]struct{ A int } // Check the object strings match. // (We can't check that types are identical because the // objects belong to different type-checker realms.) - srcstr := types.ObjectString(srcobj, (*types.Package).Name) - binstr := types.ObjectString(binobj, (*types.Package).Name) + srcstr := objectString(srcobj) + binstr := objectString(binobj) if srcstr != binstr { t.Errorf("ObjectStrings do not match: Object(For(%q)) = %s, want %s", path, srcstr, binstr) @@ -288,3 +289,13 @@ var Z map[string]struct{ A int } } } } + +func objectString(obj types.Object) string { + s := types.ObjectString(obj, (*types.Package).Name) + + // The printing of interface methods changed in go1.11. + // This work-around makes the specific test pass with earlier versions. + s = strings.Replace(s, "func (interface).Method", "func (p.Foo).Method", -1) + + return s +}