Skip to content

go/types, types2: spurious compile error when embedding a parameterized type in a struct #44688

@adonovan

Description

@adonovan

This program (https://go2goplay.golang.org/p/rF1kHzbn4Fc):

type A[T any] struct{}

func (*A[T]) f(T) {}

type B[T any] struct{ A[T] }

func main() {
	var b B[string]
	b.A.f("") // ok
	b.f("") // compile error: type *B[string] of b does not match *A[K] (cannot infer T)
}

causes go2go to emit this spurious-looking error:

prog.go2:12:2: type *B[string] of b does not match *A[T] (cannot infer T)

dev.go2go version 356c171

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