mirror of
https://github.com/golang/go
synced 2024-11-23 07:30:05 -07:00
62654dfd4f
For selector expression "x.M" where "M" is a promoted method, irgen is using the type of receiver "x" for determining the typeparams for instantiation. However, because M is a promoted method, so its associated receiver is not "x", but "x.T" where "T" is the embedded field of "x". That casues a mismatch when converting non-shape types arguments. Fixing it by using the actual receiver which has the method, instead of using the base receiver. Fixes #53982 Change-Id: I1836fc422d734df14e9e6664d4bd014503960bfc Reviewed-on: https://go-review.googlesource.com/c/go/+/419294 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
26 lines
359 B
Go
26 lines
359 B
Go
// build
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
type S[K, V any] struct {
|
|
E[V]
|
|
}
|
|
|
|
type E[K any] struct{}
|
|
|
|
func (e E[K]) M() E[K] {
|
|
return e
|
|
}
|
|
|
|
func G[K, V any](V) {
|
|
_ = (*S[K, V]).M
|
|
}
|
|
|
|
func main() {
|
|
G[*int](new(int))
|
|
}
|