2021-03-10 23:25:21 +00:00
|
|
|
// 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
|
|
|
|
|
|
|
|
type I interface{}
|
|
|
|
|
|
|
|
type _S[T any] struct {
|
2021-07-26 19:13:45 +00:00
|
|
|
x *T
|
2021-03-10 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// F is a non-generic function, but has a type _S[I] which is instantiated from a
|
|
|
|
// generic type. Test that _S[I] is successfully exported.
|
|
|
|
func F() {
|
|
|
|
v := _S[I]{}
|
2021-07-26 19:13:45 +00:00
|
|
|
if v.x != nil {
|
2021-03-10 23:25:21 +00:00
|
|
|
panic(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Testing the various combinations of method expressions.
|
|
|
|
type S1 struct{}
|
2021-07-28 20:39:30 +00:00
|
|
|
|
2021-03-10 23:25:21 +00:00
|
|
|
func (*S1) M() {}
|
|
|
|
|
|
|
|
type S2 struct{}
|
2021-07-28 20:39:30 +00:00
|
|
|
|
2021-03-10 23:25:21 +00:00
|
|
|
func (S2) M() {}
|
|
|
|
|
|
|
|
func _F1[T interface{ M() }](t T) {
|
|
|
|
_ = T.M
|
|
|
|
}
|
|
|
|
|
|
|
|
func F2() {
|
2021-07-26 19:13:45 +00:00
|
|
|
_F1(&S1{})
|
|
|
|
_F1(S2{})
|
|
|
|
_F1(&S2{})
|
2021-03-10 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
F()
|
|
|
|
F2()
|
|
|
|
}
|