mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
[dev.typeparams] test/typeparam: gofmt -w
We don't usually reformat the test directory, but all of the files in test/typeparam are syntactically valid. I suspect the misformattings here are because developers aren't re-installing gofmt with -tags=typeparams, not intentionally exercising non-standard formatting. Change-Id: I3767d480434c19225568f3c7d656dc8589197183 Reviewed-on: https://go-review.googlesource.com/c/go/+/338093 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
473e493d18
commit
5355753009
|
@ -39,7 +39,9 @@ func _[T C5[X], X any](ch T) {
|
|||
|
||||
type M0 interface{ int }
|
||||
type M1 interface{ map[string]int }
|
||||
type M2 interface { map[string]int | map[string]float64 }
|
||||
type M2 interface {
|
||||
map[string]int | map[string]float64
|
||||
}
|
||||
type M3 interface{ map[string]int | map[rune]int }
|
||||
type M4[K comparable, V any] interface{ map[K]V | map[rune]V }
|
||||
|
||||
|
|
|
@ -172,7 +172,6 @@ func globals() {
|
|||
is77(ii2())
|
||||
}
|
||||
|
||||
|
||||
func recursive() {
|
||||
if got, want := recur1[int](5), 110; got != want {
|
||||
panic(fmt.Sprintf("recur1[int](5) = %d, want = %d", got, want))
|
||||
|
|
|
@ -45,11 +45,11 @@ func k[T any](x interface{}) interface { bar() T } {
|
|||
}
|
||||
|
||||
type mybar int
|
||||
|
||||
func (x mybar) bar() int {
|
||||
return int(x)
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
var i interface{} = int(3)
|
||||
var j I = myint(3)
|
||||
|
|
|
@ -67,5 +67,3 @@ func assert(b bool) {
|
|||
panic("assertion failed")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -225,7 +225,6 @@ func TestShortestPath() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
TestShortestPath()
|
||||
}
|
||||
|
|
|
@ -79,4 +79,3 @@ func main() {
|
|||
panic(fmt.Sprintf("got %d, want %d", got, want))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,11 @@ func F() {
|
|||
|
||||
// Testing the various combinations of method expressions.
|
||||
type S1 struct{}
|
||||
|
||||
func (*S1) M() {}
|
||||
|
||||
type S2 struct{}
|
||||
|
||||
func (S2) M() {}
|
||||
|
||||
func _F1[T interface{ M() }](t T) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
type s[T any] struct {
|
||||
a T
|
||||
}
|
||||
|
||||
func (x s[T]) f() T {
|
||||
return x.a
|
||||
}
|
||||
|
|
|
@ -594,7 +594,6 @@ func TestTransform() {
|
|||
checkList(l2, []interface{}{"1", "2"})
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
TestList()
|
||||
TestExtending()
|
||||
|
@ -607,4 +606,3 @@ func main() {
|
|||
TestInsertAfterUnknownMark()
|
||||
TestTransform()
|
||||
}
|
||||
|
||||
|
|
|
@ -301,7 +301,6 @@ func TestTransform() {
|
|||
checkList(l2, []interface{}{"1", "2"})
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
TestList()
|
||||
TestExtending()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package a
|
||||
|
||||
type X int
|
||||
|
||||
func (x X) M() X { return x }
|
||||
|
||||
func F[T interface{ M() U }, U interface{ M() T }]() {}
|
||||
|
|
|
@ -25,7 +25,10 @@ func main() {
|
|||
panic(fmt.Sprintf("unexpected f2 size == %d, want %d", got, want))
|
||||
}
|
||||
|
||||
type mypair struct { f1 int32; f2 int64 }
|
||||
type mypair struct {
|
||||
f1 int32
|
||||
f2 int64
|
||||
}
|
||||
mp := mypair(p)
|
||||
if mp.f1 != 1 || mp.f2 != 2 {
|
||||
panic(fmt.Sprintf("mp == %#v, want %#v", mp, mypair{1, 2}))
|
||||
|
|
|
@ -19,7 +19,10 @@ func main() {
|
|||
panic(fmt.Sprintf("unexpected f2 size == %d, want %d", got, want))
|
||||
}
|
||||
|
||||
type mypair struct { Field1 int32; Field2 int64 }
|
||||
type mypair struct {
|
||||
Field1 int32
|
||||
Field2 int64
|
||||
}
|
||||
mp := mypair(p)
|
||||
if mp.Field1 != 1 || mp.Field2 != 2 {
|
||||
panic(fmt.Sprintf("mp == %#v, want %#v", mp, mypair{1, 2}))
|
||||
|
|
|
@ -44,7 +44,6 @@ func fromStrings1a[T any, PT Setter[T]](s []string) []PT {
|
|||
return result
|
||||
}
|
||||
|
||||
|
||||
// Takes one type parameter and a set function
|
||||
func fromStrings2[T any](s []string, set func(*T, string)) []T {
|
||||
results := make([]T, len(s))
|
||||
|
|
|
@ -33,7 +33,6 @@ func (v *value[T]) get(def T) T {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
var s value[string]
|
||||
if got, want := s.get("ab"), ""; got != want {
|
||||
|
|
|
@ -63,7 +63,6 @@ func _[V any, T interface { type map[string]V }](p T) V {
|
|||
return p["test"]
|
||||
}
|
||||
|
||||
|
||||
// Testing partial and full type inference, including the case where the types can
|
||||
// be inferred without needing the types of the function arguments.
|
||||
|
||||
|
@ -114,7 +113,12 @@ func _() {
|
|||
f4(x, []*int{}, &x)
|
||||
}
|
||||
|
||||
func f5[A interface{type struct{b B; c C}}, B any, C interface{type *B}](x B) A
|
||||
func f5[A interface {
|
||||
type struct {
|
||||
b B
|
||||
c C
|
||||
}
|
||||
}, B any, C interface{ type *B }](x B) A
|
||||
func _() {
|
||||
x := f5(1.2)
|
||||
var _ float64 = x.b
|
||||
|
|
|
@ -53,4 +53,3 @@ func main() {
|
|||
panic(fmt.Sprintf("Get() == %d, want %d", got, want))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue