diff --git a/test/gen/err001.go2 b/test/gen/err001.go2 index 49d1bc1d7e..24b865ffad 100644 --- a/test/gen/err001.go2 +++ b/test/gen/err001.go2 @@ -6,17 +6,17 @@ package p -func F1[type T comparable]() {} +func F1[T comparable]() {} func F2() { F1[[]int]() } // ERROR "\[\]int does not satisfy comparable$" type C interface { M() } -func F3[type T C]() {} +func F3[T C]() {} func F4() { F3[int]() } // ERROR "int does not satisfy C.*method M" -func F5[type T]() { F3[T]() } // ERROR "T does not satisfy C.*method M" +func F5[T any]() { F3[T]() } // ERROR "T does not satisfy C.*method M" type signed interface { type int, int8, int16, int32, int64 @@ -27,9 +27,9 @@ type integer interface { uint, uint8, uint16, uint32, uint64, uintptr } -func F6[type T signed](a T) bool { return a < 0 } -func F7[type T](a T) bool { return F6(a) } // ERROR "T does not satisfy signed.*T has no type constraints" -func F8[type T integer](a T) bool { return F6(a) } // ERROR "T does not satisfy signed.*T type constraint uint not found in" +func F6[T signed](a T) bool { return a < 0 } +func F7[T any](a T) bool { return F6(a) } // ERROR "T does not satisfy signed.*T has no type constraints" +func F8[T integer](a T) bool { return F6(a) } // ERROR "T does not satisfy signed.*T type constraint uint not found in" func F9(a uint) bool { return F6(a) } // ERROR "uint does not satisfy signed.*uint not found in" type MyInt int @@ -43,7 +43,7 @@ type C2 interface { signed } -func F20[type T C2](a T) bool { +func F20[T C2](a T) bool { a.M() return a < 0 } @@ -57,8 +57,8 @@ func (S) M() {} func F21() bool { return F20(MyInt(0)) } func F22() bool { return F20(0) } // ERROR "int does not satisfy C2.*(missing method M)" -func F23[type T](a T) bool { return F20(a) } // ERROR "T does not satisfy C2.*(missing method M)" -func F24[type T integer](a T) bool { return F20(a) } // ERROR "T does not satisfy C2.*(missing method M)" +func F23[T any](a T) bool { return F20(a) } // ERROR "T does not satisfy C2.*(missing method M)" +func F24[T integer](a T) bool { return F20(a) } // ERROR "T does not satisfy C2.*(missing method M)" func F25(a uint) bool { return F20(a) } // ERROR "uint does not satisfy C2.*(missing method M)" func F26(a MyUint) bool { return F20(a) } // ERROR "MyUint does not satisfy C2.*uint not found in" func F27(a S) bool { return F20(a) } // ERROR "S does not satisfy C2.*struct{} not found in" diff --git a/test/gen/err002.dir/b.go2 b/test/gen/err002.dir/b.go2 index a2ca06a23c..b738a4ea14 100644 --- a/test/gen/err002.dir/b.go2 +++ b/test/gen/err002.dir/b.go2 @@ -6,5 +6,5 @@ package b import "./a" -func F1[type T a.C]() {} +func F1[T a.C]() {} func F2() { F1(int)() } // ERROR "int does not satisfy a.C.*method M" diff --git a/test/gen/err003.go2 b/test/gen/err003.go2 index ca4379810b..71d0e67315 100644 --- a/test/gen/err003.go2 +++ b/test/gen/err003.go2 @@ -10,7 +10,7 @@ type Setter interface { Set(string) } -func FromStrings[type T Setter](s []string) []T { +func FromStrings[T Setter](s []string) []T { result := make([]T, len(s)) for i, v := range s { result[i].Set(v) diff --git a/test/gen/err004.go2 b/test/gen/err004.go2 index f4b10ebd96..e4846ae62d 100644 --- a/test/gen/err004.go2 +++ b/test/gen/err004.go2 @@ -7,5 +7,5 @@ package p func F() { - type t[type T] T // ERROR "parameterized type" + type t[T any] T // ERROR "parameterized type" } diff --git a/test/gen/err005.go2 b/test/gen/err005.go2 index d881c608e4..257a719db6 100644 --- a/test/gen/err005.go2 +++ b/test/gen/err005.go2 @@ -7,7 +7,7 @@ // Issue 39738. package p -func F1[type T]() {} +func F1[T any]() {} func F2() { type s struct{} diff --git a/test/gen/err006.go2 b/test/gen/err006.go2 index 7a66f93d80..6881c13d6a 100644 --- a/test/gen/err006.go2 +++ b/test/gen/err006.go2 @@ -7,7 +7,7 @@ // Issue 39743. package p -type S[type T] struct{} +type S[T any] struct{} func (s S[_]) M() {} // ERROR "_" diff --git a/test/gen/g001.go2 b/test/gen/g001.go2 index 9cca607653..cb0170e787 100644 --- a/test/gen/g001.go2 +++ b/test/gen/g001.go2 @@ -8,7 +8,7 @@ package main import "fmt" -func Print[type T](s []T) { +func Print[T any](s []T) { for _, v := range s { fmt.Println(v) } diff --git a/test/gen/g002.go2 b/test/gen/g002.go2 index e87a45cf87..29f0b9f864 100644 --- a/test/gen/g002.go2 +++ b/test/gen/g002.go2 @@ -8,13 +8,13 @@ package main import "fmt" -func Print1[type T](s []T) { +func Print1[T any](s []T) { for _, v := range s { fmt.Println(v) } } -func Print2[type T](s []T) { +func Print2[T any](s []T) { Print1(T)(s) } diff --git a/test/gen/g003.go2 b/test/gen/g003.go2 index 395c9b4ac7..813ed92a08 100644 --- a/test/gen/g003.go2 +++ b/test/gen/g003.go2 @@ -11,7 +11,7 @@ import ( "unsafe" ) -type Pair[type F1, F2] struct { +type Pair[F1, F2 any] struct { f1 F1 f2 F2 } diff --git a/test/gen/g004.go2 b/test/gen/g004.go2 index c0cfa94f60..940d6e3412 100644 --- a/test/gen/g004.go2 +++ b/test/gen/g004.go2 @@ -8,7 +8,7 @@ package main import "fmt" -type Value[type T] struct { +type Value[T any] struct { val T } diff --git a/test/gen/g005.dir/a.go2 b/test/gen/g005.dir/a.go2 index 0a59d2ade2..098d876b18 100644 --- a/test/gen/g005.dir/a.go2 +++ b/test/gen/g005.dir/a.go2 @@ -4,7 +4,7 @@ package a -type Stack[type E] []E +type Stack[E any] []E func (s *Stack[E]) Push(e E) { *s = append(*s, e) diff --git a/test/gen/g006.go2 b/test/gen/g006.go2 index 1766925b84..8171e2acd5 100644 --- a/test/gen/g006.go2 +++ b/test/gen/g006.go2 @@ -20,7 +20,7 @@ type Ordered interface { string } -type orderedSlice[type Elem Ordered] []Elem +type orderedSlice[Elem Ordered] []Elem func (s orderedSlice[Elem]) Len() int { return len(s) } func (s orderedSlice[Elem]) Less(i, j int) bool { @@ -35,7 +35,7 @@ func (s orderedSlice[Elem]) Less(i, j int) bool { } func (s orderedSlice[Elem]) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func OrderedSlice[type Elem Ordered](s []Elem) { +func OrderedSlice[Elem Ordered](s []Elem) { sort.Sort(orderedSlice[Elem](s)) } @@ -55,7 +55,7 @@ func TestSortOrderedStrings() bool { return testOrdered("strings", strings, sort.Strings) } -func testOrdered[type Elem Ordered](name string, s []Elem, sorter func([]Elem)) bool { +func testOrdered[Elem Ordered](name string, s []Elem, sorter func([]Elem)) bool { s1 := make([]Elem, len(s)) copy(s1, s) s2 := make([]Elem, len(s)) @@ -76,7 +76,7 @@ func testOrdered[type Elem Ordered](name string, s []Elem, sorter func([]Elem)) return ok } -func sliceEq[type Elem Ordered](s1, s2 []Elem) bool { +func sliceEq[Elem Ordered](s1, s2 []Elem) bool { for i, v1 := range s1 { v2 := s2[i] if v1 != v2 { diff --git a/test/gen/g007.go2 b/test/gen/g007.go2 index 94ff100fe6..57f7ee2c1e 100644 --- a/test/gen/g007.go2 +++ b/test/gen/g007.go2 @@ -9,11 +9,11 @@ package p -type S[type T] struct { +type S[T any] struct { f T } -func SliceS[type T]() S[[]T] { +func SliceS[T any]() S[[]T] { return S[[]T]{nil} } diff --git a/test/gen/g008.go2 b/test/gen/g008.go2 index 8c163dd8e2..94afbffdc4 100644 --- a/test/gen/g008.go2 +++ b/test/gen/g008.go2 @@ -10,7 +10,7 @@ type Setter interface { Set(string) } -func FromStrings[type T Setter](s []string) []T { +func FromStrings[T Setter](s []string) []T { result := make([]T, len(s)) for i, v := range s { result[i].Set(v) diff --git a/test/gen/g009.go2 b/test/gen/g009.go2 index 8e25644a2c..aa5a8fd9bb 100644 --- a/test/gen/g009.go2 +++ b/test/gen/g009.go2 @@ -11,12 +11,12 @@ import ( "strconv" ) -type Setter2[type B] interface { +type Setter2[B any] interface { Set(string) type *B } -func FromStrings2[type T interface{}, PT Setter2[T]](s []string) []T { +func FromStrings2[T any, PT Setter2[T]](s []string) []T { result := make([]T, len(s)) for i, v := range s { p := PT(&result[i]) diff --git a/test/gen/g010.go2 b/test/gen/g010.go2 index 506fb00fe7..0c4bf982cc 100644 --- a/test/gen/g010.go2 +++ b/test/gen/g010.go2 @@ -11,7 +11,7 @@ import ( "strconv" ) -func FromStrings3[type T](s []string, set func(*T, string)) []T { +func FromStrings3[T any](s []string, set func(*T, string)) []T { results := make([]T, len(s)) for i, v := range s { set(&results[i], v) diff --git a/test/gen/g011.go2 b/test/gen/g011.go2 index d862472725..ac84357afd 100644 --- a/test/gen/g011.go2 +++ b/test/gen/g011.go2 @@ -15,7 +15,7 @@ type Setter interface { Set(string) } -func FromStrings[type *T Setter](s []string) []T { +func FromStrings[*T Setter](s []string) []T { result := make([]T, len(s)) for i, v := range s { // result[i] is an addressable value of type T, diff --git a/test/gen/g012.go2 b/test/gen/g012.go2 index 4bcf76bb60..8639bcf234 100644 --- a/test/gen/g012.go2 +++ b/test/gen/g012.go2 @@ -16,14 +16,14 @@ type Numeric interface { } // NumericAbs matches numeric types with an Abs method. -type NumericAbs[type T] interface { +type NumericAbs[T any] interface { Numeric Abs() T } // AbsDifference computes the absolute value of the difference of // a and b, where the absolute value is determined by the Abs method. -func AbsDifference[type T NumericAbs](a, b T) T { +func AbsDifference[T NumericAbs](a, b T) T { d := a - b return d.Abs() } @@ -42,7 +42,7 @@ type Complex interface { // OrderedAbs is a helper type that defines an Abs method for // ordered numeric types. -type OrderedAbs[type T OrderedNumeric] T +type OrderedAbs[T OrderedNumeric] T func (a OrderedAbs[T]) Abs() OrderedAbs[T] { if a < 0 { @@ -53,7 +53,7 @@ func (a OrderedAbs[T]) Abs() OrderedAbs[T] { // ComplexAbs is a helper type that defines an Abs method for // complex types. -type ComplexAbs[type T Complex] T +type ComplexAbs[T Complex] T func (a ComplexAbs[T]) Abs() ComplexAbs[T] { r := float64(real(a)) @@ -64,13 +64,13 @@ func (a ComplexAbs[T]) Abs() ComplexAbs[T] { // OrderedAbsDifference returns the absolute value of the difference // between a and b, where a and b are of an ordered type. -func OrderedAbsDifference[type T OrderedNumeric](a, b T) T { +func OrderedAbsDifference[T OrderedNumeric](a, b T) T { return T(AbsDifference(OrderedAbs(T)(a), OrderedAbs(T)(b))) } // ComplexAbsDifference returns the absolute value of the difference // between a and b, where a and b are of a complex type. -func ComplexAbsDifference[type T Complex](a, b T) T { +func ComplexAbsDifference[T Complex](a, b T) T { return T(AbsDifference(ComplexAbs(T)(a), ComplexAbs(T)(b))) } diff --git a/test/gen/g013.go2 b/test/gen/g013.go2 index 7a2bcb3308..4a57a5335d 100644 --- a/test/gen/g013.go2 +++ b/test/gen/g013.go2 @@ -6,9 +6,9 @@ package main -type Gen[type A] func() (A, bool) +type Gen[A any] func() (A, bool) -func combine[type T1, T2, T](g1 Gen[T1], g2 Gen[T2], join func(T1, T2) T) Gen[T] { +func combine[T1, T2, T any](g1 Gen[T1], g2 Gen[T2], join func(T1, T2) T) Gen[T] { return func() (T, bool) { var t T t1, ok := g1() @@ -23,14 +23,14 @@ func combine[type T1, T2, T](g1 Gen[T1], g2 Gen[T2], join func(T1, T2) T) Gen[T] } } -type Pair[type A, B] struct { +type Pair[A, B any] struct { A A B B } -func NewPair[type A, B](a A, b B) Pair[A, B] { return Pair[A, B]{a, b} } +func NewPair[A, B any](a A, b B) Pair[A, B] { return Pair[A, B]{a, b} } -func Combine2[type A, B](ga Gen[A], gb Gen[B]) Gen[Pair[A, B]] { +func Combine2[A, B any](ga Gen[A], gb Gen[B]) Gen[Pair[A, B]] { return combine(ga, gb, NewPair(A, B)) } diff --git a/test/gen/g014.go2 b/test/gen/g014.go2 index efeb571ba6..e9d1d4dad5 100644 --- a/test/gen/g014.go2 +++ b/test/gen/g014.go2 @@ -6,7 +6,7 @@ package main -type T[type A] struct { +type T[A any] struct { V A } diff --git a/test/gen/g015.go2 b/test/gen/g015.go2 index 2d518b51c7..71d132819c 100644 --- a/test/gen/g015.go2 +++ b/test/gen/g015.go2 @@ -6,7 +6,7 @@ package p -func F1[type T](x T) {} +func F1[T any](x T) {} func F2(c <-chan int) { F1(c) diff --git a/test/gen/g016.go2 b/test/gen/g016.go2 index 2c58693380..0508687456 100644 --- a/test/gen/g016.go2 +++ b/test/gen/g016.go2 @@ -10,7 +10,7 @@ import "fmt" type Any interface{} -type Function[type a Any, b Any] interface { +type Function[a, b any] interface { Apply(x a) b } @@ -26,7 +26,7 @@ func (this pos) Apply(x int) bool { return x > 0 } -type compose[type a Any, b Any, c Any] struct { +type compose[a, b, c any] struct { f Function[a, b] g Function[b, c] } @@ -35,7 +35,7 @@ func (this compose[a, b, c]) Apply(x a) c { return this.g.Apply(this.f.Apply(x)) } -type Eq[type a] interface { +type Eq[a any] interface { Equal(a) bool } @@ -45,17 +45,17 @@ func (this Int) Equal(that int) bool { return int(this) == that } -type List[type a Any] interface { +type List[a any] interface { Match(casenil Function[Nil[a], Any], casecons Function[Cons[a], Any]) Any } -type Nil[type a Any] struct{} +type Nil[a any] struct{} func (xs Nil[a]) Match(casenil Function[Nil[a], Any], casecons Function[Cons[a], Any]) Any { return casenil.Apply(xs) } -type Cons[type a Any] struct { +type Cons[a any] struct { Head a Tail List[a] } @@ -64,13 +64,13 @@ func (xs Cons[a]) Match(casenil Function[Nil[a], Any], casecons Function[Cons[a] return casecons.Apply(xs) } -type mapNil[type a Any, b Any] struct{} +type mapNil[a, b any] struct{} func (m mapNil[a, b]) Apply(_ Nil[a]) Any { return Nil[b]{} } -type mapCons[type a Any, b Any] struct { +type mapCons[a, b any] struct { f Function[a, b] } @@ -78,7 +78,7 @@ func (m mapCons[a, b]) Apply(xs Cons[a]) Any { return Cons[b]{m.f.Apply(xs.Head), Map[a, b](m.f, xs.Tail)} } -func Map[type a, b Any](f Function[a, b], xs List[a]) List[b] { +func Map[a, b any](f Function[a, b], xs List[a]) List[b] { return xs.Match(mapNil[a, b]{}, mapCons[a, b]{f}).(List[b]) } diff --git a/test/gen/g017.go2 b/test/gen/g017.go2 index 1c478c5ea5..1becc9c0f5 100644 --- a/test/gen/g017.go2 +++ b/test/gen/g017.go2 @@ -8,11 +8,11 @@ package main type Recv <-chan int -type sliceOf[type E] interface { +type sliceOf[E any] interface { type []E } -func Append[type S sliceOf[T], T interface{}](s S, t ...T) S { +func Append[S sliceOf[T], T any](s S, t ...T) S { return append(s, t...) } diff --git a/test/gen/g019.go2 b/test/gen/g019.go2 index e6e903689e..5ca57c93db 100644 --- a/test/gen/g019.go2 +++ b/test/gen/g019.go2 @@ -13,7 +13,7 @@ func (*S1) M() {} type S2 struct{} func (S2) M() {} -func F1[type T interface{ M() }](t T) { +func F1[T interface{ M() }](t T) { _ = T.M } diff --git a/test/gen/g020.go2 b/test/gen/g020.go2 index 6f9dd172b8..420035d71b 100644 --- a/test/gen/g020.go2 +++ b/test/gen/g020.go2 @@ -9,12 +9,12 @@ package p type E struct{} -type N[type T] struct { +type N[T any] struct { i int n T } -func F1[type T](i int, n T) N[T] { +func F1[T any](i int, n T) N[T] { return N[T]{i: i, n: n} } diff --git a/test/gen/g021.go2 b/test/gen/g021.go2 index 69c34a21c2..8b025bc707 100644 --- a/test/gen/g021.go2 +++ b/test/gen/g021.go2 @@ -10,7 +10,7 @@ import "sync" // A Lockable is a value that may be safely simultaneously accessed // from multiple goroutines via the Get and Set methods. -type Lockable[type T] struct { +type Lockable[T any] struct { T mu sync.Mutex } diff --git a/test/gen/g022.go2 b/test/gen/g022.go2 index 4d640c0fb2..ce5977d955 100644 --- a/test/gen/g022.go2 +++ b/test/gen/g022.go2 @@ -6,6 +6,6 @@ package p -type F[type T] func(T) error +type F[T any] func(T) error type instF = F[int] diff --git a/test/gen/g023.go2 b/test/gen/g023.go2 index 7094543b2e..f2affeea6f 100644 --- a/test/gen/g023.go2 +++ b/test/gen/g023.go2 @@ -8,7 +8,7 @@ package p import "net/url" -type S[type T] struct { +type S[T any] struct { f T } diff --git a/test/gen/g024.go2 b/test/gen/g024.go2 index 578b8c297d..6ae53af1e2 100644 --- a/test/gen/g024.go2 +++ b/test/gen/g024.go2 @@ -7,7 +7,7 @@ // Issue 39672 package p -type S[type T] T +type S[T any] T func (r S[T]) M() @@ -16,7 +16,7 @@ func F() { _ = x } -func G[type T](v T) +func G[T any](v T) func F2() { G(0) diff --git a/test/gen/g025.go2 b/test/gen/g025.go2 index 34c262f230..0e6d5bd60e 100644 --- a/test/gen/g025.go2 +++ b/test/gen/g025.go2 @@ -7,17 +7,17 @@ // Issue 39692 package p -type S1[type T1, T2] struct { +type S1[T1, T2 any] struct { f1 T1 f2 T2 } -type S2[type T1, T2] struct { +type S2[T1, T2 any] struct { f1 T1 f2 T2 } -func F1[type T](v T) T { +func F1[T any](v T) T { return v } diff --git a/test/gen/g026.go2 b/test/gen/g026.go2 index 17fcfab1fe..0122307617 100644 --- a/test/gen/g026.go2 +++ b/test/gen/g026.go2 @@ -9,7 +9,7 @@ package main import "io/ioutil" -func F[type T1, T2](f func(T1) (T2, error)) {} +func F[T1, T2 any](f func(T1) (T2, error)) {} func main() { F(ioutil.ReadAll) diff --git a/test/gen/g027.go2 b/test/gen/g027.go2 index 78ed876363..b268df0b8b 100644 --- a/test/gen/g027.go2 +++ b/test/gen/g027.go2 @@ -7,7 +7,7 @@ // Issue 39678, 39881. package p -type B[type T] struct { +type B[T any] struct { T } @@ -21,7 +21,7 @@ func F(s BC) { s.F = 7 } -type Pair[type T, U] struct { +type Pair[T, U any] struct { T U } diff --git a/test/gen/g028.go2 b/test/gen/g028.go2 index 00307a8d65..8d263d0e8b 100644 --- a/test/gen/g028.go2 +++ b/test/gen/g028.go2 @@ -7,7 +7,7 @@ // Issue 39688. package p -type S[type T] T +type S[T any] T func (*S[T]) M() {} diff --git a/test/gen/g029.go2 b/test/gen/g029.go2 index 6b323e43d7..94072b77ac 100644 --- a/test/gen/g029.go2 +++ b/test/gen/g029.go2 @@ -7,7 +7,7 @@ // Issue 39741. package p -func F[type T]() { +func F[T any]() { type S struct{} } diff --git a/test/gen/g030.dir/a.go2 b/test/gen/g030.dir/a.go2 index 65800e83e2..e32797cf26 100644 --- a/test/gen/g030.dir/a.go2 +++ b/test/gen/g030.dir/a.go2 @@ -4,7 +4,7 @@ package main -func Len[type T](s []T) int { +func Len[T any](s []T) int { return len(s) } diff --git a/test/gen/g031.go2 b/test/gen/g031.go2 index 546ff1282c..c2e5ff5994 100644 --- a/test/gen/g031.go2 +++ b/test/gen/g031.go2 @@ -7,7 +7,7 @@ // Issue 39737. package p -func F1[type T]() {} +func F1[T any]() {} func F2() { F1(struct { F string `json:"f"` })() diff --git a/test/gen/g032.go2 b/test/gen/g032.go2 index c0a48ed242..1901b86917 100644 --- a/test/gen/g032.go2 +++ b/test/gen/g032.go2 @@ -9,7 +9,7 @@ package p import "net/http" -func F1[type T](f func() T) { f() } +func F1[T any](f func() T) { f() } func F2() { F1(func() *http.Request { return nil }) diff --git a/test/gen/g033.dir/a.go2 b/test/gen/g033.dir/a.go2 index 929272c6b8..1048354a1b 100644 --- a/test/gen/g033.dir/a.go2 +++ b/test/gen/g033.dir/a.go2 @@ -4,6 +4,6 @@ package a -type S[type T] struct { +type S[T any] struct { F T } diff --git a/test/gen/g034.go2 b/test/gen/g034.go2 index 0c30094c56..83a1cc2e79 100644 --- a/test/gen/g034.go2 +++ b/test/gen/g034.go2 @@ -8,7 +8,7 @@ package p type I interface{} -type S[type T] struct { +type S[T any] struct { *T } diff --git a/test/gen/g035.dir/a.go2 b/test/gen/g035.dir/a.go2 index aeb2fbff01..04d848d6ed 100644 --- a/test/gen/g035.dir/a.go2 +++ b/test/gen/g035.dir/a.go2 @@ -4,6 +4,6 @@ package a -type S[type T] struct { +type S[T any] struct { f T } diff --git a/test/gen/g035.dir/b.go2 b/test/gen/g035.dir/b.go2 index de84880195..c4a48469bc 100644 --- a/test/gen/g035.dir/b.go2 +++ b/test/gen/g035.dir/b.go2 @@ -8,7 +8,7 @@ import "./a" type S = a.S -func F1[type T](T) {} +func F1[T any](T) {} func F2() { F1(S[string]{}) } diff --git a/test/gen/g036.dir/a.go2 b/test/gen/g036.dir/a.go2 index d6a464f689..2ec4445a48 100644 --- a/test/gen/g036.dir/a.go2 +++ b/test/gen/g036.dir/a.go2 @@ -4,10 +4,10 @@ package a -type S[type T] struct { +type S[T any] struct { F T } -func NewS[type T](v T) S[T] { +func NewS[T any](v T) S[T] { return S[T]{F: v} } diff --git a/test/gen/g036.dir/b.go2 b/test/gen/g036.dir/b.go2 index 0c6179139d..46bb989d84 100644 --- a/test/gen/g036.dir/b.go2 +++ b/test/gen/g036.dir/b.go2 @@ -6,11 +6,11 @@ package main import "./a" -type S[type T] struct { +type S[T any] struct { F T } -func NewS[type T](v T) S[T] { +func NewS[T any](v T) S[T] { return S[T]{F: v} } diff --git a/test/gen/g037.dir/a.go2 b/test/gen/g037.dir/a.go2 index 4b07ac9370..b49ab07c52 100644 --- a/test/gen/g037.dir/a.go2 +++ b/test/gen/g037.dir/a.go2 @@ -6,6 +6,6 @@ package a func F() {} -func G[type T]() { +func G[T any]() { F() } diff --git a/test/gen/g038.go2 b/test/gen/g038.go2 index 61072ce164..2c08e93f25 100644 --- a/test/gen/g038.go2 +++ b/test/gen/g038.go2 @@ -6,7 +6,7 @@ package main -func F[type T comparable](a T) bool { +func F[T comparable](a T) bool { return a == a } diff --git a/test/gen/g039.go2 b/test/gen/g039.go2 index dc22a2fc1b..b829a45f12 100644 --- a/test/gen/g039.go2 +++ b/test/gen/g039.go2 @@ -6,15 +6,15 @@ package p -type top[type T, T2] struct { +type top[T, T2 any] struct { p *parent[T, T2] } -type parent[type T, T2] struct { +type parent[T, T2 any] struct { child[T, T2] } -type child[type T, T2] struct { +type child[T, T2 any] struct { T2 } diff --git a/test/gen/g040.go2 b/test/gen/g040.go2 index 393d09f618..6942f3b58f 100644 --- a/test/gen/g040.go2 +++ b/test/gen/g040.go2 @@ -6,11 +6,11 @@ package p -type S1[type T] struct{} +type S1[T any] struct{} -type S2[type K comparable] struct{} +type S2[K comparable] struct{} -type S3[type K comparable] struct { +type S3[K comparable] struct { f map[K]*S1[*S2[K]] }