mirror of
https://github.com/golang/go
synced 2024-11-02 08:01:26 +00:00
[dev.typeparams] test: rename blank functions
This CL renames blank functions in the test/ directory so that they don't rely on the compiler doing anything more than typechecking them. In particular, I ran this search to find files that used blank functions and methods: $ git grep -l '^func.*\b_(' | xargs grep -n '^' | grep '\.go:1:' | grep -v '// errorcheck$' I then skipped updating a few files: * blank.go * fixedbugs/issue11699.go * fixedbugs/issue29870.go These tests specifically check that blank functions/methods work. * interface/fail.go Not sure the motivation for the blank method here, but it's empty anyway. * typeparam/tparam1.go Type-checking test, but uses "-G" (to use types2 instead of typecheck). Updates #47446. Change-Id: I9ec1714f499808768bd0dcd7ae6016fb2b078e5e Reviewed-on: https://go-review.googlesource.com/c/go/+/338094 Trust: Matthew Dempsky <mdempsky@google.com> 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
5355753009
commit
adedf54288
11 changed files with 28 additions and 28 deletions
|
@ -173,13 +173,13 @@ type U int
|
||||||
func (*U) M() {}
|
func (*U) M() {}
|
||||||
func (_ *U) N() {}
|
func (_ *U) N() {}
|
||||||
|
|
||||||
func _() {
|
func fbad24305a() {
|
||||||
var u U
|
var u U
|
||||||
u.M()
|
u.M()
|
||||||
u.N()
|
u.N()
|
||||||
}
|
}
|
||||||
|
|
||||||
func fbad24305() {
|
func fbad24305b() {
|
||||||
var u U
|
var u U
|
||||||
(*U).M(&u)
|
(*U).M(&u)
|
||||||
(*U).N(&u)
|
(*U).N(&u)
|
||||||
|
|
|
@ -10,7 +10,7 @@ package escape
|
||||||
|
|
||||||
var x bool
|
var x bool
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
var p *int
|
var p *int
|
||||||
loop:
|
loop:
|
||||||
if x {
|
if x {
|
||||||
|
@ -22,7 +22,7 @@ loop:
|
||||||
_ = p
|
_ = p
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f2() {
|
||||||
var p *int
|
var p *int
|
||||||
if x {
|
if x {
|
||||||
loop:
|
loop:
|
||||||
|
@ -33,7 +33,7 @@ func _() {
|
||||||
_ = p
|
_ = p
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f3() {
|
||||||
var p *int
|
var p *int
|
||||||
if x {
|
if x {
|
||||||
loop:
|
loop:
|
||||||
|
|
|
@ -10,7 +10,7 @@ type T []int
|
||||||
|
|
||||||
var a []bool
|
var a []bool
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
if a[T{42}[0]] {
|
if a[T{42}[0]] {
|
||||||
}
|
}
|
||||||
// if (a[T{42}[0]]) {} // this compiles
|
// if (a[T{42}[0]]) {} // this compiles
|
||||||
|
|
|
@ -13,12 +13,12 @@ import . "bytes"
|
||||||
|
|
||||||
var _ Reader // use "bytes" import
|
var _ Reader // use "bytes" import
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
Buffer := 0
|
Buffer := 0
|
||||||
_ = Buffer
|
_ = Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f2() {
|
||||||
for Buffer := range []int{} {
|
for Buffer := range []int{} {
|
||||||
_ = Buffer
|
_ = Buffer
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,19 @@ package p
|
||||||
|
|
||||||
var sink interface{}
|
var sink interface{}
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
var t T
|
var t T
|
||||||
f := t.noescape // ERROR "t.noescape does not escape"
|
f := t.noescape // ERROR "t.noescape does not escape"
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f2() {
|
||||||
var t T // ERROR "moved to heap"
|
var t T // ERROR "moved to heap"
|
||||||
f := t.escape // ERROR "t.escape does not escape"
|
f := t.escape // ERROR "t.escape does not escape"
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f3() {
|
||||||
var t T // ERROR "moved to heap"
|
var t T // ERROR "moved to heap"
|
||||||
f := t.returns // ERROR "t.returns does not escape"
|
f := t.returns // ERROR "t.returns does not escape"
|
||||||
sink = f()
|
sink = f()
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (r *impl) Foo() Barer {
|
||||||
|
|
||||||
func (r *impl) Bar() {}
|
func (r *impl) Bar() {}
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
var r Fooer = &impl{}
|
var r Fooer = &impl{}
|
||||||
r.Foo().Bar()
|
r.Foo().Bar()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
goto L1
|
goto L1
|
||||||
const x = 0
|
const x = 0
|
||||||
L1:
|
L1:
|
||||||
|
@ -18,7 +18,7 @@ L1:
|
||||||
L2:
|
L2:
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f2() {
|
||||||
{
|
{
|
||||||
goto L1
|
goto L1
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ L1:
|
||||||
L2:
|
L2:
|
||||||
}
|
}
|
||||||
|
|
||||||
func _(d int) {
|
func f3(d int) {
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
goto L1
|
goto L1
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,17 +10,17 @@
|
||||||
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
func _() {
|
func f1() {
|
||||||
type C chan int
|
type C chan int
|
||||||
_ = [1][]C{[]C{make(chan int)}}
|
_ = [1][]C{[]C{make(chan int)}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f2() {
|
||||||
type C interface{}
|
type C interface{}
|
||||||
_ = [1][]C{[]C{recover()}}
|
_ = [1][]C{[]C{recover()}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() {
|
func f3() {
|
||||||
type C *int
|
type C *int
|
||||||
_ = [1][]C{[]C{new(int)}}
|
_ = [1][]C{[]C{new(int)}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func j(x int) int { // ERROR "can inline j"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _() int { // ERROR "can inline _"
|
func f2() int { // ERROR "can inline f2"
|
||||||
tmp1 := h
|
tmp1 := h
|
||||||
tmp2 := tmp1
|
tmp2 := tmp1
|
||||||
return tmp2(0) // ERROR "inlining call to h"
|
return tmp2(0) // ERROR "inlining call to h"
|
||||||
|
@ -167,7 +167,7 @@ func (T) meth(int, int) {} // ERROR "can inline T.meth"
|
||||||
|
|
||||||
func k() (T, int, int) { return T{}, 0, 0 } // ERROR "can inline k"
|
func k() (T, int, int) { return T{}, 0, 0 } // ERROR "can inline k"
|
||||||
|
|
||||||
func _() { // ERROR "can inline _"
|
func f3() { // ERROR "can inline f3"
|
||||||
T.meth(k()) // ERROR "inlining call to k" "inlining call to T.meth"
|
T.meth(k()) // ERROR "inlining call to k" "inlining call to T.meth"
|
||||||
// ERRORAUTO "inlining call to T.meth"
|
// ERRORAUTO "inlining call to T.meth"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ func f[T any]() (f, g T) { return f, g }
|
||||||
// Tests for generic function instantiation on the right hande side of multi-value
|
// Tests for generic function instantiation on the right hande side of multi-value
|
||||||
// assignments.
|
// assignments.
|
||||||
|
|
||||||
func _() {
|
func g() {
|
||||||
// Multi-value assignment within a function
|
// Multi-value assignment within a function
|
||||||
var _, _ = f[int]()
|
var _, _ = f[int]()
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,14 +69,14 @@ func _[V any, T interface{ type map[string]V }](p T) V {
|
||||||
// Cannot embed stand-alone type parameters. Disabled for now.
|
// Cannot embed stand-alone type parameters. Disabled for now.
|
||||||
/*
|
/*
|
||||||
func f0[A any, B interface{type C}, C interface{type D}, D interface{type A}](A, B, C, D)
|
func f0[A any, B interface{type C}, C interface{type D}, D interface{type A}](A, B, C, D)
|
||||||
func _() {
|
func f0x() {
|
||||||
f := f0[string]
|
f := f0[string]
|
||||||
f("a", "b", "c", "d")
|
f("a", "b", "c", "d")
|
||||||
f0("a", "b", "c", "d")
|
f0("a", "b", "c", "d")
|
||||||
}
|
}
|
||||||
|
|
||||||
func f1[A any, B interface{type A}](A, B)
|
func f1[A any, B interface{type A}](A, B)
|
||||||
func _() {
|
func f1x() {
|
||||||
f := f1[int]
|
f := f1[int]
|
||||||
f(int(0), int(0))
|
f(int(0), int(0))
|
||||||
f1(int(0), int(0))
|
f1(int(0), int(0))
|
||||||
|
@ -86,7 +86,7 @@ func _() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func f2[A any, B interface{ type []A }](_ A, _ B)
|
func f2[A any, B interface{ type []A }](_ A, _ B)
|
||||||
func _() {
|
func f2x() {
|
||||||
f := f2[byte]
|
f := f2[byte]
|
||||||
f(byte(0), []byte{})
|
f(byte(0), []byte{})
|
||||||
f2(byte(0), []byte{})
|
f2(byte(0), []byte{})
|
||||||
|
@ -97,7 +97,7 @@ func _() {
|
||||||
// Cannot embed stand-alone type parameters. Disabled for now.
|
// Cannot embed stand-alone type parameters. Disabled for now.
|
||||||
/*
|
/*
|
||||||
func f3[A any, B interface{type C}, C interface{type *A}](a A, _ B, c C)
|
func f3[A any, B interface{type C}, C interface{type *A}](a A, _ B, c C)
|
||||||
func _() {
|
func f3x() {
|
||||||
f := f3[int]
|
f := f3[int]
|
||||||
var x int
|
var x int
|
||||||
f(x, &x, &x)
|
f(x, &x, &x)
|
||||||
|
@ -106,7 +106,7 @@ func _() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func f4[A any, B interface{ type []C }, C interface{ type *A }](_ A, _ B, c C)
|
func f4[A any, B interface{ type []C }, C interface{ type *A }](_ A, _ B, c C)
|
||||||
func _() {
|
func f4x() {
|
||||||
f := f4[int]
|
f := f4[int]
|
||||||
var x int
|
var x int
|
||||||
f(x, []*int{}, &x)
|
f(x, []*int{}, &x)
|
||||||
|
@ -119,14 +119,14 @@ func f5[A interface {
|
||||||
c C
|
c C
|
||||||
}
|
}
|
||||||
}, B any, C interface{ type *B }](x B) A
|
}, B any, C interface{ type *B }](x B) A
|
||||||
func _() {
|
func f5x() {
|
||||||
x := f5(1.2)
|
x := f5(1.2)
|
||||||
var _ float64 = x.b
|
var _ float64 = x.b
|
||||||
var _ float64 = *x.c
|
var _ float64 = *x.c
|
||||||
}
|
}
|
||||||
|
|
||||||
func f6[A any, B interface{ type struct{ f []A } }](B) A
|
func f6[A any, B interface{ type struct{ f []A } }](B) A
|
||||||
func _() {
|
func f6x() {
|
||||||
x := f6(struct{ f []string }{})
|
x := f6(struct{ f []string }{})
|
||||||
var _ string = x
|
var _ string = x
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue