Skip to content

cmd/go2go: compile error in some cases of method expressions on type parameters #39662

@Carrotman42

Description

@Carrotman42

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

The Go 2 dev playground at https://go2goplay.golang.org/

What did you do?

Full example: https://go2goplay.golang.org/p/U43Cljg2tvj

Excerpt:

type I interface {
	F()
}

func takesI(type T I)(t T) {
	_ = T.F
}

func workaround(type T I)(t T) {
	_ = (T).F
}

As shown in the full example in the playground link above, calling takesI with T = *SomeType results in compilation failing. Calling workaround is fine, and since the only difference is the manual wrapping of parenthesis this indicates to me that the generated code is just missing grouping of its own which is causing the errors.

What did you see instead?

Error messages during compilation:

./prog.go2:4: invalid method expression P.F (needs pointer receiver: (*P).F)
./prog.go2:4: invalid indirect of V.F (type func(V))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions