Skip to content

go/types: embedded interface behavior now dependent on file name ordering #28005

Closed
@ccbrown

Description

@ccbrown

What version of Go are you using (go version)?

Go 1.11 and 1.11.1.

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

darwin/amd64

What did you do?

Type-checked a package that contains interfaces that embed interfaces from other files within the same package.

For example, I have an interface in a.go:

type A interface {
    A()
}

and an interface in e.go:

type E interface {
    E()
}

and an interface in c.go that embeds those two:

type SuperInterface interface {
    A
    E
}

What did you expect to see?

Up through Go 1.10, type-checking the package and printing out the method set would always produce this:

func (github.com/ccbrown/go-file-ordering-bug/thepackage.A).A()
func (github.com/ccbrown/go-file-ordering-bug/thepackage.E).E()

What did you see instead?

Type-checking treats A a bit differently than E. Printing out the method set gives us something like this:

func (github.com/ccbrown/go-file-ordering-bug/thepackage.A).A()
func (github.com/ccbrown/go-file-ordering-bug/thepackage.SuperInterface).E()

And simply renaming the files changes the output of this.

Demo Project

Check out this project: https://github.com/ccbrown/go-file-ordering-bug

Just run go run main.go. The output will be different for Go 1.10 and 1.11.

This makes tooling such as @dominikh's unused tool break in Go 1.11 for certain cases where interfaces are only used by other interfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.SoonThis needs action soon. (recent regressions, service outages, unusual time-sensitive situations)release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions