| 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 = 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 |