test/typeparam/issue47877.go
raw| 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 Map[K comparable, V any] struct { |
| 10 | m map[K]V |
| 11 | } |
| 12 | |
| 13 | func NewMap[K comparable, V any]() Map[K, V] { |
| 14 | return Map[K, V]{m: map[K]V{}} |
| 15 | } |
| 16 | |
| 17 | func (m Map[K, V]) Get(key K) V { |
| 18 | return m.m[key] |
| 19 | } |
| 20 | |
| 21 | func main() { |
| 22 | _ = NewMap[int, struct{}]() |
| 23 | } |