Debian Codegraph @

gopls/internal/test/marker/testdata/codeaction/extract_variable-67905.txt

raw
1 This test verifies the fix for golang/go#67905: Extract variable from type
2 switch produces invalid code
3
4 -- go.mod --
5 module mod.test/extract
6
7 go 1.18
8
9 -- extract_switch.go --
10 package extract
11
12 import (
13 "io"
14 )
15
16 func f() io.Reader
17
18 func main() {
19 switch r := f().(type) { //@codeaction("f()", "refactor.extract.variable", edit=type_switch_func_call)
20 default:
21 _ = r
22 }
23 }
24
25 -- @type_switch_func_call/extract_switch.go --
26 @@ -10 +10,2 @@
27 - switch r := f().(type) { //@codeaction("f()", "refactor.extract.variable", edit=type_switch_func_call)
28 + newVar := f()
29 + switch r := newVar.(type) { //@codeaction("f()", "refactor.extract.variable", edit=type_switch_func_call)