]> Cypherpunks.ru repositories - gostls13.git/blob - test/typeparam/append.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / typeparam / append.go
1 // run
2
3 // Copyright 2021 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 package main
8
9 type Recv <-chan int
10
11 type sliceOf[E any] interface {
12         ~[]E
13 }
14
15 func _Append[S sliceOf[T], T any](s S, t ...T) S {
16         return append(s, t...)
17 }
18
19 func main() {
20         recv := make(Recv)
21         a := _Append([]Recv{recv}, recv)
22         if len(a) != 2 || a[0] != recv || a[1] != recv {
23                 panic(a)
24         }
25
26         recv2 := make(chan<- int)
27         a2 := _Append([]chan<- int{recv2}, recv2)
28         if len(a2) != 2 || a2[0] != recv2 || a2[1] != recv2 {
29                 panic(a)
30         }
31 }