-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.13.7 linux/amd64
What did you do?
package main
import (
"fmt"
"go/ast"
"go/importer"
"go/parser"
"go/token"
"go/types"
"log"
"reflect"
"golang.org/x/tools/go/types/typeutil"
)
const input = `
package abc
type Conn struct {
frameReader
PayloadType int
}
type frameReader interface {
PayloadType() byte
}
`
var fset = token.NewFileSet()
func main() {
f, err := parser.ParseFile(fset, "hello.go", input, 0)
if err != nil {
log.Fatal(err)
}
conf := types.Config{Importer: importer.Default()}
info := &types.Info{Types: make(map[ast.Expr]types.TypeAndValue)}
pkg, err := conf.Check("cmd/hello", fset, []*ast.File{f}, info)
if err != nil {
log.Fatal(err)
}
ct := pkg.Scope().Lookup("Conn").Type()
var cache typeutil.MethodSetCache
var methetset = cache.MethodSet(ct)
fmt.Println(methetset)
// MethodSet {
// method (cmd/hello.Conn) PayloadType() byte
// }
fmt.Println(reflect.TypeOf(Conn{}).NumMethod())
// 0
}
type Conn struct {
frameReader
PayloadType int
}
type frameReader interface {
PayloadType() byte
}
What did you expect to see?
Type Conn
has no methods.
What did you see instead?
Type Conn
has one method.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.