Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit ffe8890

Browse files
committed
cmd/stringer: revert CL 40403
Revert "cmd/stringer: use source importer when available" This reverts CL 40403. The idea is to avoid type-checking and use just parsing, which should be enough for stringer. Separately reopening golang/go#10249 because the original change closed that issue, but the change is itself causing other problems as described in the discussion at golang/go#25650. This reversion restores the old behavior of stringer and will be followed with other fixes if they can be worked out. Change-Id: I8404d78da08043ede1a36b0e135a3fc7fdf6728d Reviewed-on: https://go-review.googlesource.com/121884 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent b23eb62 commit ffe8890

File tree

4 files changed

+3
-34
lines changed

4 files changed

+3
-34
lines changed

cmd/stringer/endtoend_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestEndToEnd(t *testing.T) {
3333
defer os.RemoveAll(dir)
3434
// Create stringer in temporary directory.
3535
stringer := filepath.Join(dir, "stringer.exe")
36-
err = run("go", "build", "-o", stringer)
36+
err = run("go", "build", "-o", stringer, "stringer.go")
3737
if err != nil {
3838
t.Fatalf("building stringer: %s", err)
3939
}

cmd/stringer/importer18.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

cmd/stringer/importer19.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

cmd/stringer/stringer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import (
6666
"go/build"
6767
exact "go/constant"
6868
"go/format"
69+
"go/importer"
6970
"go/parser"
7071
"go/token"
7172
"go/types"
@@ -268,7 +269,7 @@ func (g *Generator) parsePackage(directory string, names []string, text interfac
268269
// check type-checks the package. The package must be OK to proceed.
269270
func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {
270271
pkg.defs = make(map[*ast.Ident]types.Object)
271-
config := types.Config{Importer: defaultImporter(), FakeImportC: true}
272+
config := types.Config{Importer: importer.Default(), FakeImportC: true}
272273
info := &types.Info{
273274
Defs: pkg.defs,
274275
}

0 commit comments

Comments
 (0)