Skip to content

cmd/compile: static itab construction fails when a type has multiple non-exported methods #24693

@mdempsky

Description

@mdempsky

In reflect.go:genfun, the code to walk method sets in parallel to compute itab entries doesn't take packages into account for finding the right non-exported method. This causes the code below to print FAIL instead of ok, because it selects U.m instead of T.m for the itab.

$ cat z.go
package z

type T int
func (T) m() { println("ok") }

func F(i interface{ m() }) { i.m() }

$ cat main.go
package main

import "./z"

type U struct{ z.T }
func (U) m() { println("FAIL") }

func main() { z.F(U{}) }

$ go tool compile z.go
$ go tool compile main.go
$ go tool link main.o
$ ./a.out
FAIL

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe 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