mirror of
https://github.com/golang/go
synced 2024-11-05 15:06:09 -07:00
cmd/vet: roll back update of go/types import
(from importing golang.org/x/tools/go/types to std lib go/types) The cmd/vet package should never have been included in this change. Tested with 1.4.1, 1.5 and ~1.6 (tip). Change-Id: I6d915619cbfa0297dbb9aa9ba033c1320a08c367 Reviewed-on: https://go-review.googlesource.com/18385 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
4747062949
commit
da91609d88
@ -11,7 +11,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -6,10 +6,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/types"
|
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -18,12 +18,14 @@ import (
|
|||||||
"go/parser"
|
"go/parser"
|
||||||
"go/printer"
|
"go/printer"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
_ "golang.org/x/tools/go/gcimporter"
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -12,7 +12,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -10,12 +10,13 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
exact "go/constant"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/exact"
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var printfuncs = flag.String("printfuncs", "", "comma-separated list of print function names to check")
|
var printfuncs = flag.String("printfuncs", "", "comma-separated list of print function names to check")
|
||||||
|
@ -34,7 +34,8 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var strictShadowing = flag.Bool("shadowstrict", false, "whether to be strict about shadowing; can be noisy")
|
var strictShadowing = flag.Bool("shadowstrict", false, "whether to be strict about shadowing; can be noisy")
|
||||||
|
@ -10,9 +10,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
exact "go/constant"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/exact"
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -8,9 +8,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/importer"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// imports is the canonical map of imported packages we need for typechecking.
|
// imports is the canonical map of imported packages we need for typechecking.
|
||||||
@ -18,8 +18,6 @@ import (
|
|||||||
var imports = make(map[string]*types.Package)
|
var imports = make(map[string]*types.Package)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultImporter = importer.Default()
|
|
||||||
|
|
||||||
errorType *types.Interface
|
errorType *types.Interface
|
||||||
stringerType *types.Interface // possibly nil
|
stringerType *types.Interface // possibly nil
|
||||||
formatterType *types.Interface // possibly nil
|
formatterType *types.Interface // possibly nil
|
||||||
@ -41,7 +39,7 @@ func init() {
|
|||||||
// path.name, and adds the respective package to the imports map
|
// path.name, and adds the respective package to the imports map
|
||||||
// as a side effect. In case of an error, importType returns nil.
|
// as a side effect. In case of an error, importType returns nil.
|
||||||
func importType(path, name string) types.Type {
|
func importType(path, name string) types.Type {
|
||||||
pkg, err := defaultImporter.Import(path)
|
pkg, err := types.DefaultImport(imports, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// This can happen if the package at path hasn't been compiled yet.
|
// This can happen if the package at path hasn't been compiled yet.
|
||||||
warnf("import failed: %v", err)
|
warnf("import failed: %v", err)
|
||||||
@ -61,7 +59,9 @@ func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) error {
|
|||||||
pkg.spans = make(map[types.Object]Span)
|
pkg.spans = make(map[types.Object]Span)
|
||||||
pkg.types = make(map[ast.Expr]types.TypeAndValue)
|
pkg.types = make(map[ast.Expr]types.TypeAndValue)
|
||||||
config := types.Config{
|
config := types.Config{
|
||||||
Importer: defaultImporter,
|
// We provide the same packages map for all imports to ensure
|
||||||
|
// that everybody sees identical packages for the given paths.
|
||||||
|
Packages: imports,
|
||||||
// By providing a Config with our own error function, it will continue
|
// By providing a Config with our own error function, it will continue
|
||||||
// past the first error. There is no need for that function to do anything.
|
// past the first error. There is no need for that function to do anything.
|
||||||
Error: func(error) {},
|
Error: func(error) {},
|
||||||
|
@ -9,7 +9,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -11,8 +11,9 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var unusedFuncsFlag = flag.String("unusedfuncs",
|
var unusedFuncsFlag = flag.String("unusedfuncs",
|
||||||
|
Loading…
Reference in New Issue
Block a user