Skip to content

cmd/compile: cannot convert v (variable of type *Bar[T]) to type *Foo[T] #52529

@b97tsk

Description

@b97tsk

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.

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