Skip to content

spec: clarify method sets and recursive promotions #15708

@mdempsky

Description

@mdempsky

My reading of the Go spec is that this is valid:

package p

type S1 struct { *S2 }
type S2 struct { *S1 }

func (*S1) M() {}

var _ = S1.M

Rationale:

  1. Because of func (*S1) M() {}, M is a member of *S1's method set.
  2. Because of the *S1 embedding into S2, M is also a member of S2 and *S2's method sets.
  3. Because of the *S2 embedding into S1, M should also be a member of S1's method set.

However, cmd/compile, gccgo, and gotype all reject it.

/cc @griesemer @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions