cmd/compile: do not set n.Type.Sym in typecheckdeftype

typecheckdef calls typecheckdeftype, which will also set n.Type.Sym,
causing duplicated work. So do not set n.Type.Sym in typecheckdeftype to
prevent this, and also keep populating n.Type info in one place make
more sense.

Change-Id: I62671babd750f9d5d0bbfcf8d7eecd2cc314c955
Reviewed-on: https://go-review.googlesource.com/c/go/+/179579
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
LE Manh Cuong 2019-05-30 23:01:37 +07:00 committed by Matthew Dempsky
parent 2393d16147
commit b136267b87

View File

@ -3496,7 +3496,6 @@ func typecheckdeftype(n *Node) {
defer tracePrint("typecheckdeftype", n)(nil)
}
n.Type.Sym = n.Sym
n.SetTypecheck(1)
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype)
t := n.Name.Param.Ntype.Type
@ -3673,7 +3672,7 @@ func typecheckdef(n *Node) {
}
n.SetWalkdef(1)
setTypeNode(n, types.New(TFORW))
n.Type.Sym = n.Sym // TODO(gri) this also happens in typecheckdeftype(n) - where should it happen?
n.Type.Sym = n.Sym
nerrors0 := nerrors
typecheckdeftype(n)
if n.Type.Etype == TFORW && nerrors > nerrors0 {