go/test/typeparam/issue50417.go
Robert Griesemer c1e7c518ae test/typeparam: adjust test preamble (fix longtests)
For #50417.

Change-Id: Ic55727c454ec342354f7fbffd22aa350e0d392c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/376174
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07 01:36:17 +00:00

71 lines
928 B
Go

// run -gcflags=-G=3
// 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
func main() {}
type Sf struct {
f int
}
func f0[P Sf](p P) {
_ = p.f
p.f = 0
}
func f0t[P ~struct{ f int }](p P) {
_ = p.f
p.f = 0
}
// TODO(danscales) enable once the compiler is fixed
// var _ = f0[Sf]
// var _ = f0t[Sf]
func f1[P interface {
Sf
m()
}](p P) {
_ = p.f
p.f = 0
p.m()
}
type Sm struct{}
func (Sm) m() {}
type Sfm struct {
f int
}
func (Sfm) m() {}
func f2[P interface {
Sfm
m()
}](p P) {
_ = p.f
p.f = 0
p.m()
}
// TODO(danscales) enable once the compiler is fixed
// var _ = f2[Sfm]
// special case: structural type is a named pointer type
type PSfm *Sfm
func f3[P interface{ PSfm }](p P) {
_ = p.f
p.f = 0
}
// TODO(danscales) enable once the compiler is fixed
// var _ = f3[PSfm]