notes map[string][]*Note
// declarations
- imports map[string]int
- values []*Value // consts and vars
- types map[string]*namedType
- funcs methodSet
+ imports map[string]int
+ hasDotImp bool // if set, package contains a dot import
+ values []*Value // consts and vars
+ types map[string]*namedType
+ funcs methodSet
// support for package-local error type declarations
errorDecl bool // if set, type "error" was declared locally
if s, ok := spec.(*ast.ImportSpec); ok {
if import_, err := strconv.Unquote(s.Path.Value); err == nil {
r.imports[import_] = 1
+ if s.Name != nil && s.Name.Name == "." {
+ r.hasDotImp = true
+ }
}
}
}
func (r *reader) cleanupTypes() {
for _, t := range r.types {
visible := r.isVisible(t.name)
- if t.decl == nil && (predeclaredTypes[t.name] || t.isEmbedded && visible) {
+ if t.decl == nil && (predeclaredTypes[t.name] || visible && (t.isEmbedded || r.hasDotImp)) {
// t.name is a predeclared type (and was not redeclared in this package),
// or it was embedded somewhere but its declaration is missing (because
- // the AST is incomplete): move any associated values, funcs, and methods
- // back to the top-level so that they are not lost.
+ // the AST is incomplete), or we have a dot-import (and all bets are off):
+ // move any associated values, funcs, and methods back to the top-level so
+ // that they are not lost.
// 1) move values
r.values = append(r.values, t.values...)
// 2) move factory functions
--- /dev/null
+// Copyright 2016 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 issue13742
+
+import (
+ "go/ast"
+ . "go/ast"
+)
+
+// Both F0 and G0 should appear as functions.
+func F0(Node) {}
+func G0() Node { return nil }
+
+// Both F1 and G1 should appear as functions.
+func F1(ast.Node) {}
+func G1() ast.Node { return nil }