// Find unresolved identifiers and uses of top-level declarations.
depDecls, unresolved := findDeclsAndUnresolved(body, topDecls, typMethods)
- // Remove predeclared identifiers from unresolved list.
- for n := range unresolved {
- if predeclaredTypes[n] || predeclaredConstants[n] || predeclaredFuncs[n] {
- delete(unresolved, n)
- }
- }
-
// Use unresolved identifiers to determine the imports used by this
// example. The heuristic assumes package names match base import
// paths for imports w/o renames (should be good enough most of the time).
}
}
+ // Remove predeclared identifiers from unresolved list.
+ for n := range unresolved {
+ if predeclaredTypes[n] || predeclaredConstants[n] || predeclaredFuncs[n] {
+ delete(unresolved, n)
+ }
+ }
+
// If there are other unresolved identifiers, give up because this
// synthesized file is not going to build.
if len(unresolved) > 0 {
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package foo_test
+
+import (
+ "fmt"
+
+ "example.com/error"
+)
+
+func Print(s string) {
+ fmt.Println(s)
+}
+
+func Example() {
+ Print(error.Hello)
+}