Skip to content

Commit

Permalink
cmd/stringer: revert CL 40403
Browse files Browse the repository at this point in the history
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 <iant@golang.org>
  • Loading branch information
robpike committed Jul 3, 2018
1 parent 2c68937 commit b9ebdf9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 34 deletions.
2 changes: 1 addition & 1 deletion endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestEndToEnd(t *testing.T) {
defer os.RemoveAll(dir)
// Create stringer in temporary directory.
stringer := filepath.Join(dir, "stringer.exe")
err = run("go", "build", "-o", stringer)
err = run("go", "build", "-o", stringer, "stringer.go")
if err != nil {
t.Fatalf("building stringer: %s", err)
}
Expand Down
16 changes: 0 additions & 16 deletions importer18.go

This file was deleted.

16 changes: 0 additions & 16 deletions importer19.go

This file was deleted.

3 changes: 2 additions & 1 deletion stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
"go/build"
exact "go/constant"
"go/format"
"go/importer"
"go/parser"
"go/token"
"go/types"
Expand Down Expand Up @@ -268,7 +269,7 @@ func (g *Generator) parsePackage(directory string, names []string, text interfac
// check type-checks the package. The package must be OK to proceed.
func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {
pkg.defs = make(map[*ast.Ident]types.Object)
config := types.Config{Importer: defaultImporter(), FakeImportC: true}
config := types.Config{Importer: importer.Default(), FakeImportC: true}
info := &types.Info{
Defs: pkg.defs,
}
Expand Down

0 comments on commit b9ebdf9

Please sign in to comment.