}
func importsym(ipkg *types.Pkg, pos src.XPos, s *types.Sym, op Op) *Node {
- n := asNode(s.Def)
+ n := asNode(s.PkgDef())
if n == nil {
// iimport should have created a stub ONONAME
// declaration for all imported symbols. The exception
}
n = dclname(s)
- s.Def = asTypesNode(n)
+ s.SetPkgDef(asTypesNode(n))
s.Importdef = ipkg
}
if n.Op != ONONAME && n.Op != op {
// PkgDef returns the definition associated with s at package scope.
func (s *Sym) PkgDef() *Node {
+ return *s.pkgDefPtr()
+}
+
+// SetPkgDef sets the definition associated with s at package scope.
+func (s *Sym) SetPkgDef(n *Node) {
+ *s.pkgDefPtr() = n
+}
+
+func (s *Sym) pkgDefPtr() **Node {
// Look for outermost saved declaration, which must be the
// package scope definition, if present.
for _, d := range dclstack {
if s == d.sym {
- return d.def
+ return &d.def
}
}
// Otherwise, the declaration hasn't been shadowed within a
// function scope.
- return s.Def
+ return &s.Def
}
--- /dev/null
+// Copyright 2018 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 p
+
+type m struct {
+ link *m
+}
+
+var head *m
+
+func F(m *int) bool {
+ return head != nil
+}
--- /dev/null
+// Copyright 2018 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 q
+
+import "./p"
+
+func G() {
+ p.F(nil)
+}
--- /dev/null
+// compiledir
+
+// Copyright 2018 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 ignored