Skip to content

Commit adedf54

Browse files
committedJul 28, 2021
[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 golang#47446. Change-Id: I9ec1714f499808768bd0dcd7ae6016fb2b078e5e Reviewed-on: https://go-review.googlesource.com/c/go/+/338094 Trust: Matthew Dempsky <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 5355753 commit adedf54

11 files changed

+28
-28
lines changed
 

‎test/escape5.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ type U int
173173
func (*U) M() {}
174174
func (_ *U) N() {}
175175

176-
func _() {
176+
func fbad24305a() {
177177
var u U
178178
u.M()
179179
u.N()
180180
}
181181

182-
func fbad24305() {
182+
func fbad24305b() {
183183
var u U
184184
(*U).M(&u)
185185
(*U).N(&u)

‎test/escape_goto.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package escape
1010

1111
var x bool
1212

13-
func _() {
13+
func f1() {
1414
var p *int
1515
loop:
1616
if x {
@@ -22,7 +22,7 @@ loop:
2222
_ = p
2323
}
2424

25-
func _() {
25+
func f2() {
2626
var p *int
2727
if x {
2828
loop:
@@ -33,7 +33,7 @@ func _() {
3333
_ = p
3434
}
3535

36-
func _() {
36+
func f3() {
3737
var p *int
3838
if x {
3939
loop:

‎test/fixedbugs/bug267.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type T []int
1010

1111
var a []bool
1212

13-
func _() {
13+
func f1() {
1414
if a[T{42}[0]] {
1515
}
1616
// if (a[T{42}[0]]) {} // this compiles

‎test/fixedbugs/issue22076.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import . "bytes"
1313

1414
var _ Reader // use "bytes" import
1515

16-
func _() {
16+
func f1() {
1717
Buffer := 0
1818
_ = Buffer
1919
}
2020

21-
func _() {
21+
func f2() {
2222
for Buffer := range []int{} {
2323
_ = Buffer
2424
}

‎test/fixedbugs/issue27557.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ package p
88

99
var sink interface{}
1010

11-
func _() {
11+
func f1() {
1212
var t T
1313
f := t.noescape // ERROR "t.noescape does not escape"
1414
f()
1515
}
1616

17-
func _() {
17+
func f2() {
1818
var t T // ERROR "moved to heap"
1919
f := t.escape // ERROR "t.escape does not escape"
2020
f()
2121
}
2222

23-
func _() {
23+
func f3() {
2424
var t T // ERROR "moved to heap"
2525
f := t.returns // ERROR "t.returns does not escape"
2626
sink = f()

‎test/fixedbugs/issue45258.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (r *impl) Foo() Barer {
2222

2323
func (r *impl) Bar() {}
2424

25-
func _() {
25+
func f1() {
2626
var r Fooer = &impl{}
2727
r.Foo().Bar()
2828
}

‎test/fixedbugs/issue8042.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
package p
1111

12-
func _() {
12+
func f1() {
1313
goto L1
1414
const x = 0
1515
L1:
@@ -18,7 +18,7 @@ L1:
1818
L2:
1919
}
2020

21-
func _() {
21+
func f2() {
2222
{
2323
goto L1
2424
}
@@ -31,7 +31,7 @@ L1:
3131
L2:
3232
}
3333

34-
func _(d int) {
34+
func f3(d int) {
3535
if d > 0 {
3636
goto L1
3737
} else {

‎test/fixedbugs/issue8761.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
package p
1212

13-
func _() {
13+
func f1() {
1414
type C chan int
1515
_ = [1][]C{[]C{make(chan int)}}
1616
}
1717

18-
func _() {
18+
func f2() {
1919
type C interface{}
2020
_ = [1][]C{[]C{recover()}}
2121
}
2222

23-
func _() {
23+
func f3() {
2424
type C *int
2525
_ = [1][]C{[]C{new(int)}}
2626
}

‎test/inline.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func j(x int) int { // ERROR "can inline j"
4949
}
5050
}
5151

52-
func _() int { // ERROR "can inline _"
52+
func f2() int { // ERROR "can inline f2"
5353
tmp1 := h
5454
tmp2 := tmp1
5555
return tmp2(0) // ERROR "inlining call to h"
@@ -167,7 +167,7 @@ func (T) meth(int, int) {} // ERROR "can inline T.meth"
167167

168168
func k() (T, int, int) { return T{}, 0, 0 } // ERROR "can inline k"
169169

170-
func _() { // ERROR "can inline _"
170+
func f3() { // ERROR "can inline f3"
171171
T.meth(k()) // ERROR "inlining call to k" "inlining call to T.meth"
172172
// ERRORAUTO "inlining call to T.meth"
173173
}

‎test/typeparam/issue45547.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func f[T any]() (f, g T) { return f, g }
1111
// Tests for generic function instantiation on the right hande side of multi-value
1212
// assignments.
1313

14-
func _() {
14+
func g() {
1515
// Multi-value assignment within a function
1616
var _, _ = f[int]()
1717
}

‎test/typeparam/typelist.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func _[V any, T interface{ type map[string]V }](p T) V {
6969
// Cannot embed stand-alone type parameters. Disabled for now.
7070
/*
7171
func f0[A any, B interface{type C}, C interface{type D}, D interface{type A}](A, B, C, D)
72-
func _() {
72+
func f0x() {
7373
f := f0[string]
7474
f("a", "b", "c", "d")
7575
f0("a", "b", "c", "d")
7676
}
7777
7878
func f1[A any, B interface{type A}](A, B)
79-
func _() {
79+
func f1x() {
8080
f := f1[int]
8181
f(int(0), int(0))
8282
f1(int(0), int(0))
@@ -86,7 +86,7 @@ func _() {
8686
*/
8787

8888
func f2[A any, B interface{ type []A }](_ A, _ B)
89-
func _() {
89+
func f2x() {
9090
f := f2[byte]
9191
f(byte(0), []byte{})
9292
f2(byte(0), []byte{})
@@ -97,7 +97,7 @@ func _() {
9797
// Cannot embed stand-alone type parameters. Disabled for now.
9898
/*
9999
func f3[A any, B interface{type C}, C interface{type *A}](a A, _ B, c C)
100-
func _() {
100+
func f3x() {
101101
f := f3[int]
102102
var x int
103103
f(x, &x, &x)
@@ -106,7 +106,7 @@ func _() {
106106
*/
107107

108108
func f4[A any, B interface{ type []C }, C interface{ type *A }](_ A, _ B, c C)
109-
func _() {
109+
func f4x() {
110110
f := f4[int]
111111
var x int
112112
f(x, []*int{}, &x)
@@ -119,14 +119,14 @@ func f5[A interface {
119119
c C
120120
}
121121
}, B any, C interface{ type *B }](x B) A
122-
func _() {
122+
func f5x() {
123123
x := f5(1.2)
124124
var _ float64 = x.b
125125
var _ float64 = *x.c
126126
}
127127

128128
func f6[A any, B interface{ type struct{ f []A } }](B) A
129-
func _() {
129+
func f6x() {
130130
x := f6(struct{ f []string }{})
131131
var _ string = x
132132
}

0 commit comments

Comments
 (0)
Please sign in to comment.