1// run
2
3// Copyright 2022 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
9type Elem struct{}
10
11func (*Elem) Wait(callback func()) {}
12
13type Base struct {
14	elem [8]*Elem
15}
16
17var g_val = 1
18
19func (s *Base) Do() *int {
20	resp := &g_val
21	for _, e := range s.elem {
22		e.Wait(func() {
23			*resp = 0
24		})
25	}
26	return resp
27}
28
29type Sub struct {
30	*Base
31}
32
33func main() {
34	a := Sub{new(Base)}
35	resp := a.Do()
36	if resp != nil && *resp != 1 {
37		panic("FAIL")
38	}
39}
40