Skip to content

Commit 1ee389b

Browse files
committed
internal/regtest: fix regtests for the dev.typeparams Go branch
TestFillStruct had an unnecessary dependency on the go/types.Info API. Break the dependency. Change-Id: I7cacd045487e3a7d2ba92a6f76f6b37e0ea33bfb Reviewed-on: https://go-review.googlesource.com/c/tools/+/293929 Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> (cherry picked from commit 1f00549) Reviewed-on: https://go-review.googlesource.com/c/tools/+/294912 Reviewed-by: Rebecca Stambler <[email protected]>
1 parent 0919917 commit 1ee389b

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

gopls/internal/regtest/misc/fix_test.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,35 @@ go 1.14
2323
-- main.go --
2424
package main
2525
26-
import "go/types"
26+
type Info struct {
27+
WordCounts map[string]int
28+
Words []string
29+
}
2730
2831
func Foo() {
29-
_ = types.Info{}
32+
_ = Info{}
3033
}
3134
`
3235
Run(t, basic, func(t *testing.T, env *Env) {
3336
env.OpenFile("main.go")
37+
pos := env.RegexpSearch("main.go", "Info{}").ToProtocolPosition()
3438
if err := env.Editor.RefactorRewrite(env.Ctx, "main.go", &protocol.Range{
35-
Start: protocol.Position{
36-
Line: 5,
37-
Character: 16,
38-
},
39-
End: protocol.Position{
40-
Line: 5,
41-
Character: 16,
42-
},
39+
Start: pos,
40+
End: pos,
4341
}); err != nil {
4442
t.Fatal(err)
4543
}
4644
want := `package main
4745
48-
import "go/types"
46+
type Info struct {
47+
WordCounts map[string]int
48+
Words []string
49+
}
4950
5051
func Foo() {
51-
_ = types.Info{
52-
Types: map[ast.Expr]types.TypeAndValue{},
53-
Defs: map[*ast.Ident]types.Object{},
54-
Uses: map[*ast.Ident]types.Object{},
55-
Implicits: map[ast.Node]types.Object{},
56-
Selections: map[*ast.SelectorExpr]*types.Selection{},
57-
Scopes: map[ast.Node]*types.Scope{},
58-
InitOrder: []*types.Initializer{},
52+
_ = Info{
53+
WordCounts: map[string]int{},
54+
Words: []string{},
5955
}
6056
}
6157
`

0 commit comments

Comments
 (0)