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

cmd/go: Generate type has no method on type redefine #55010

Closed
RelicOfTesla opened this issue Sep 12, 2022 · 1 comment
Closed

cmd/go: Generate type has no method on type redefine #55010

RelicOfTesla opened this issue Sep 12, 2022 · 1 comment

Comments

@RelicOfTesla
Copy link

RelicOfTesla commented Sep 12, 2022

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

$ go version
go version go1.18.3 windows/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env

What did you do?

type TestT[T any] struct {
	V T
}

func (TestT[T]) Hello1() {
	fmt.Println("hello")
}

type TestInt1 TestT[int]
type TestInt2 TestT[int]
type TestInt3 = TestT[int]

func TestGoType(t *testing.T) {
	var (
		v1 TestInt1
		v2 TestInt2
		v3 TestInt3
		v4 TestT[int]
	)
	v1.Hello1() // v1.Hello1 undefined (type TestInt1 has no field or method Hello1)
	v2.Hello1() // v2.Hello1 undefined (type TestInt2 has no field or method Hello1)
	v3.Hello1()
	v4.Hello1()
	v3 = v4
	//v1 != v2
}

What did you expect to see?

Support call method.

What did you see instead?

undefined (type TestInt1 has no field or method Hello1)

@RelicOfTesla RelicOfTesla changed the title cmd/go: Generate type has no field or method on type redefine cmd/go: Generate type has no method on type redefine Sep 12, 2022
@seankhliao
Copy link
Member

Like all type declarations, methods are cleared out.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2022
@golang golang locked and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants