]> Cypherpunks.ru repositories - gostls13.git/blob - test/alg.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / alg.go
1 // build
2
3 // Copyright 2016 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 // This file tests that required algs are generated,
8 // even when similar types have been marked elsewhere
9 // as not needing algs. See CLs 19769 and 19770.
10
11 package main
12
13 import "fmt"
14
15 //go:noinline
16 func f(m map[[8]string]int) int {
17         var k [8]string
18         return m[k]
19 }
20
21 //go:noinline
22 func g(m map[[8]interface{}]int) int {
23         var k [8]interface{}
24         return m[k]
25 }
26
27 //go:noinline
28 func h(m map[[2]string]int) int {
29         var k [2]string
30         return m[k]
31 }
32
33 type T map[string]interface{}
34
35 func v(x ...string) string {
36         return x[0] + x[1]
37 }
38
39 func main() {
40         fmt.Println(
41                 f(map[[8]string]int{}),
42                 g(map[[8]interface{}]int{}),
43                 h(map[[2]string]int{}),
44                 v("a", "b"),
45         )
46 }