go issue50755 源码

  • 2022-07-15
  • 浏览 (673)

golang issue50755 代码

文件路径:/src/cmd/compile/internal/types2/testdata/fixedbugs/issue50755.go

// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

// The core type of M2 unifies with the type of m1
// during function argument type inference.
// M2's constraint is unnamed.
func f1[K1 comparable, E1 any](m1 map[K1]E1) {}

func f2[M2 map[string]int](m2 M2) {
	f1(m2)
}

// The core type of M3 unifies with the type of m1
// during function argument type inference.
// M3's constraint is named.
type Map3 map[string]int

func f3[M3 Map3](m3 M3) {
	f1(m3)
}

// The core type of M5 unifies with the core type of M4
// during constraint type inference.
func f4[M4 map[K4]int, K4 comparable](m4 M4) {}

func f5[M5 map[K5]int, K5 comparable](m5 M5) {
	f4(m5)
}

// test case from issue

func Copy[MC ~map[KC]VC, KC comparable, VC any](dst, src MC) {
	for k, v := range src {
		dst[k] = v
	}
}

func Merge[MM ~map[KM]VM, KM comparable, VM any](ms ...MM) MM {
	result := MM{}
	for _, m := range ms {
		Copy(result, m)
	}
	return result
}

相关信息

go 源码目录

相关文章

go issue20583 源码

go issue23203a 源码

go issue23203b 源码

go issue25838 源码

go issue26390 源码

go issue28251 源码

go issue39634 源码

go issue39664 源码

go issue39680 源码

go issue39693 源码

0  赞