GoPLS Viewer

Home|gopls/go/callgraph/vta/testdata/src/maps.go
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
7package testdata
8
9type I interface {
10    Foo() string
11}
12
13type J interface {
14    Foo() string
15    Bar()
16}
17
18type B struct {
19    p string
20}
21
22func (b BFoo() string { return b.p }
23func (b BBar()        {}
24
25func Baz(m map[I]Ib1b2 Bn map[string]*J) *J {
26    m[b1] = b2
27
28    return n[b1.Foo()]
29}
30
31// Relevant SSA:
32// func Baz(m map[I]I, b1 B, b2 B, n map[string]*J) *J:
33//   t0 = local B (b1)
34//   *t0 = b1
35//   t1 = local B (b2)
36//   *t1 = b2
37//   t2 = *t0
38//   t3 = make I <- B (t2)
39//   t4 = *t1
40//   t5 = make I <- B (t4)
41//   m[t3] = t5
42//   t6 = *t0
43//   t7 = (B).Foo(t6)
44//   t8 = n[t7]
45//   return t8
46
47// WANT:
48// Local(t4) -> Local(t5)
49// Local(t5) -> MapValue(testdata.I)
50// Local(t3) -> MapKey(testdata.I)
51// Local(t8) -> MapValue(*testdata.J)
52// MapValue(*testdata.J) -> Local(t8)
53
MembersX
Baz.b2
Baz.n
Baz.m
Baz.b1
Members
X