1// run
2
3// Copyright 2019 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// Make sure the runtime can scan args of an unstarted goroutine
8// which starts with a reflect-generated function.
9
10package main
11
12import (
13	"reflect"
14	"runtime"
15)
16
17const N = 100
18
19type T struct {
20}
21
22func (t *T) Foo(c chan bool) {
23	c <- true
24}
25
26func main() {
27	t := &T{}
28	runtime.GOMAXPROCS(1)
29	c := make(chan bool, N)
30	for i := 0; i < N; i++ {
31		f := reflect.ValueOf(t).MethodByName("Foo").Interface().(func(chan bool))
32		go f(c)
33	}
34	runtime.GC()
35	for i := 0; i < N; i++ {
36		<-c
37	}
38}
39