| 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 |
|
| 7 |
package main |
| 8 |
|
| 9 |
type Elem struct{} |
| 10 |
|
| 11 |
func (*Elem) Wait(callback func()) {} |
| 12 |
|
| 13 |
type Base struct { |
| 14 |
elem [8]*Elem |
| 15 |
} |
| 16 |
|
| 17 |
var g_val = 1 |
| 18 |
|
| 19 |
func (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 |
|
| 29 |
type Sub struct { |
| 30 |
*Base |
| 31 |
} |
| 32 |
|
| 33 |
func main() { |
| 34 |
a := Sub{new(Base)} |
| 35 |
resp := a.Do() |
| 36 |
if resp != nil && *resp != 1 { |
| 37 |
panic("FAIL") |
| 38 |
} |
| 39 |
} |