Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/ssa: unexpected type for conversion between type parameters #64324

Closed
zpavlinovic opened this issue Nov 21, 2023 · 1 comment
Closed
Assignees
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zpavlinovic
Copy link
Contributor

Consider the following piece of code:

type bar[T any] interface {
        Bar(int)
}

type foo[T any] interface {
        bar[T]
        *T
}

func Foo[T any, F foo[T]](d int) {
        m := new(T)
        F(m).Bar(d)
}

I expected that type of the receiver object F(m) is foo[T]. However, it seems that ssa assignes it type T. Here is the output of ssadump.

func Foo[T any, F foo[T]](d int):
0:                                                                entry P:0 S:0
        t0 = new T (new)                                                     *T
        t1 = changetype F <- *T (t0)                                          F
        t2 = *t1                                                              T
        t3 = invoke t2.Bar(d)                                                ()
        return
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 21, 2023
@gopherbot gopherbot added this to the Unreleased milestone Nov 21, 2023
@gopherbot
Copy link

Change https://go.dev/cl/548375 mentions this issue: go/ssa: do not load type parameter method receivers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants