3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test situations where functions/methods are not
8 // immediately called and we need to capture the dictionary
9 // required for later invocation.
23 func g1[T any](x T) T {
26 func g2[T any](x T) (T, T) {
42 panic("assertion failed")
48 panic("assertion failed")
52 type s[T any] struct {
58 func (x s[T]) g1() T {
61 func (x s[T]) g2() (T, T) {
65 func methodExpressions() {
90 var y interface{} = s[int]{a: 7}
92 func interfaceMethods() {
96 y.(interface{ g0() }).g0()
97 is7(y.(interface{ g1() int }).g1())
98 is77(y.(interface{ g2() (int, int) }).g2())
101 // Also check for instantiations outside functions.
110 var xtop = s[int]{a: 7}