Skip to content

Commit 526de61

Browse files
wdvxdr1123gopherbot
authored andcommitted
test: add test case for #51840
This issue has been fixed in CL 403837. Fixes #51840. Change-Id: I282062bb06278696fe25e9ede333c64539dc964e Reviewed-on: https://go-review.googlesource.com/c/go/+/404914 Run-TryBot: Wayne Zuo <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Auto-Submit: Matthew Dempsky <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent bf68170 commit 526de61

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/typeparam/issue51840.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// compile
2+
3+
// Copyright 2022 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 Addr struct {
10+
hi uint64
11+
lo uint64
12+
z *byte
13+
}
14+
15+
func EqualMap[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {
16+
for k, v1 := range m1 {
17+
if v2, ok := m2[k]; !ok || v1 != v2 {
18+
return false
19+
}
20+
}
21+
return true
22+
}
23+
24+
type Set[T comparable] map[T]struct{}
25+
26+
func NewSet[T comparable](items ...T) Set[T] {
27+
return nil
28+
}
29+
30+
func (s Set[T]) Equals(other Set[T]) bool {
31+
return EqualMap(s, other)
32+
}
33+
34+
func main() {
35+
NewSet[Addr](Addr{0, 0, nil})
36+
}

0 commit comments

Comments
 (0)