1// run -gcflags="-G=3"
2
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.
6
7package main
8
9import (
10	"reflect"
11)
12
13type A[T any] struct {
14	B[int]
15}
16
17type B[T any] struct {
18}
19
20func (b B[T]) Bat() {
21	t := new(T)
22	if tt := reflect.TypeOf(t); tt.Kind() != reflect.Pointer || tt.Elem().Kind() != reflect.Int {
23		panic("unexpected type, want: *int, got: "+tt.String())
24	}
25}
26
27type Foo struct {
28	A[string]
29}
30func main() {
31	Foo{}.A.Bat()
32	Foo{}.A.B.Bat()
33	Foo{}.Bat()
34}
35