1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package p 6 7 type Number1 interface { 8 // embedding non-interface types is permitted 9 int 10 float64 11 } 12 13 func Add1[T Number1](a, b T) T { 14 return a /* ERROR "not defined" */ + b 15 } 16 17 type Number2 interface { 18 int | float64 19 } 20 21 func Add2[T Number2](a, b T) T { 22 return a + b 23 } 24