1 | // Copyright 2021 The Go Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style |
3 | // license that can be found in the LICENSE file. |
4 | |
5 | // go:build ignore |
6 | |
7 | package testdata |
8 | |
9 | func Foo() {} |
10 | |
11 | func Do(b bool) func() { |
12 | if b { |
13 | return Foo |
14 | } |
15 | return func() {} |
16 | } |
17 | |
18 | func Finish(h func()) { |
19 | h() |
20 | } |
21 | |
22 | func Baz(b bool) { |
23 | Finish(Do(b)) |
24 | } |
25 | |
26 | // Relevant SSA: |
27 | // func Baz(b bool): |
28 | // t0 = Do(b) |
29 | // t1 = Finish(t0) |
30 | // return |
31 | |
32 | // func Do(b bool) func(): |
33 | // if b goto 1 else 2 |
34 | // 1: |
35 | // return Foo |
36 | // 2: |
37 | // return Do$1 |
38 | |
39 | // func Finish(h func()): |
40 | // t0 = h() |
41 | // return |
42 | |
43 | // WANT: |
44 | // Baz: Do(b) -> Do; Finish(t0) -> Finish |
45 | // Finish: h() -> Do$1, Foo |
46 |