mirror of
https://github.com/golang/go
synced 2024-11-17 08:24:43 -07:00
04f65d394c
We were handling the case where an OFUNCINST node was used as a function value, but not the case when an OFUNCINST node was used as a method value. In the case of a method value, we need to create a new selector expression that references the newly stenciled method. To make this work, also needed small fix to noder2 code to properly set the Sel of a method SelectorExpr (should be just the base method name, not the full method name including the type string). This has to be correct, so that the function created by MethodValueWrapper() can be typechecked successfully. Fixes #45817 Change-Id: I7343e8a0d35fc46b44dfe4d45b77997ba6c8733e Reviewed-on: https://go-review.googlesource.com/c/go/+/319589 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
26 lines
418 B
Go
26 lines
418 B
Go
// run -gcflags=-G=3
|
|
|
|
// Copyright 2021 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
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type s[T any] struct {
|
|
a T
|
|
}
|
|
func (x s[T]) f() T {
|
|
return x.a
|
|
}
|
|
func main() {
|
|
x := s[int]{a:7}
|
|
f := x.f
|
|
if got, want := f(), 7; got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
}
|