maps: permit Copy between two diffent generic map types

Fixes golang/go#52593

Change-Id: I0d4fe48561f209f140f4035b099224015e30a5d6
Reviewed-on: https://go-review.googlesource.com/c/exp/+/408894
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
diff --git a/maps/maps.go b/maps/maps.go
index fc27cd1..f49768b 100644
--- a/maps/maps.go
+++ b/maps/maps.go
@@ -74,7 +74,7 @@
 // When a key in src is already present in dst,
 // the value in dst will be overwritten by the value associated
 // with the key in src.
-func Copy[M ~map[K]V, K comparable, V any](dst, src M) {
+func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
 	for k, v := range src {
 		dst[k] = v
 	}
diff --git a/maps/maps_test.go b/maps/maps_test.go
index 6dc6292..c21ef30 100644
--- a/maps/maps_test.go
+++ b/maps/maps_test.go
@@ -153,6 +153,10 @@
 	if !Equal(mc, want) {
 		t.Errorf("Copy result = %v, want %v", mc, want)
 	}
+
+	type M1 map[int]bool
+	type M2 map[int]bool
+	Copy(make(M1), make(M2))
 }
 
 func TestDeleteFunc(t *testing.T) {