What version of Go are you using (go version)?
$ go version
go version go1.18.1 windows/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
Irrelevant.
What did you do?
package main
type Foo[T any] struct {
_ *Bar[T]
}
type Bar[T any] Foo[T]
func (v *Bar[T]) M() {
_ = (*Foo[T])(v)
}
func main() {}
What did you expect to see?
The code compiles.
What did you see instead?
main.go:10:16: cannot convert v (variable of type *Bar[T]) to type *Foo[T]
The code does compile if the compiler sees type Bar first.