golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/go/callgraph/vta/testdata/src/maps.go (about) 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 type I interface { 10 Foo() string 11 } 12 13 type J interface { 14 Foo() string 15 Bar() 16 } 17 18 type B struct { 19 p string 20 } 21 22 func (b B) Foo() string { return b.p } 23 func (b B) Bar() {} 24 25 func Baz(m map[I]I, b1, b2 B, n 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 = make I <- B (b1) 34 // t1 = make I <- B (b2) 35 // m[t0] = t1 36 // t2 = (B).Foo(b1) 37 // t3 = n[t2] 38 // return t3 39 40 // WANT: 41 // Local(b2) -> Local(t1) 42 // Local(t1) -> MapValue(testdata.I) 43 // Local(t0) -> MapKey(testdata.I) 44 // Local(t3) -> MapValue(*testdata.J) 45 // MapValue(*testdata.J) -> Local(t3)