Skip to content

cmd/compile: generic function instantiated with wrong type #48253

@korzhao

Description

@korzhao

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

go tip 1.18

$ go version

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import (
	"fmt"
	"reflect"
)

type A[T any] struct {
	B[int]
}
type B[T any] struct {
}
func (b B[T]) Bat() {
	t := new(T)
	fmt.Println(reflect.TypeOf(t).String())
}

type Foo struct {
	A[string]
}
func main() {
	Foo{}.A.Bat()
	Foo{}.A.B.Bat()
}

What did you expect to see?

*int
*int

What did you see instead?

*string
*int

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