diff --git a/go/analysis/analysistest/analysistest.go b/go/analysis/analysistest/analysistest.go index 25062c68..ad979c14 100644 --- a/go/analysis/analysistest/analysistest.go +++ b/go/analysis/analysistest/analysistest.go @@ -263,6 +263,9 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis // Check the facts match expectations. // Report errors in lexical order for determinism. + // (It's only deterministic within each file, not across files, + // because go/packages does not guarantee file.Pos is ascending + // across the files of a single compilation unit.) var objects []types.Object for obj := range facts { objects = append(objects, obj) diff --git a/go/analysis/passes/copylock/copylock.go b/go/analysis/passes/copylock/copylock.go index e684cd37..c199c2ea 100644 --- a/go/analysis/passes/copylock/copylock.go +++ b/go/analysis/passes/copylock/copylock.go @@ -258,6 +258,15 @@ func lockPath(tpkg *types.Package, typ types.Type) typePath { return []types.Type{typ} } + // In go1.10, sync.noCopy did not implement Locker. + // (The Unlock method was added only in CL 121876.) + // TODO(adonovan): remove workaround when we drop go1.10. + if named, ok := typ.(*types.Named); ok && + named.Obj().Name() == "noCopy" && + named.Obj().Pkg().Path() == "sync" { + return []types.Type{typ} + } + nfields := styp.NumFields() for i := 0; i < nfields; i++ { ftyp := styp.Field(i).Type() diff --git a/go/analysis/passes/copylock/copylock_test.go b/go/analysis/passes/copylock/copylock_test.go index 3e4ca122..acbdb52a 100644 --- a/go/analysis/passes/copylock/copylock_test.go +++ b/go/analysis/passes/copylock/copylock_test.go @@ -7,7 +7,7 @@ import ( "golang.org/x/tools/go/analysis/passes/copylock" ) -func TestFromFileSystem(t *testing.T) { +func Test(t *testing.T) { testdata := analysistest.TestData() analysistest.Run(t, testdata, copylock.Analyzer, "a") }