]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: tweak anonymous parameter position
authorMatthew Dempsky <mdempsky@google.com>
Mon, 17 May 2021 21:25:49 +0000 (14:25 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 19 May 2021 06:26:57 +0000 (06:26 +0000)
When declaring anonymous parameters, use the syntax.Field's Pos
directly rather than its Type field's Pos. When the type expression is
a qualified identifier (i.e., SelectorExpr), its Pos returns the
position of the dot, whereas we typically declare the anonymous
parameter at the starting position of the type. (We could equivalently
use syntax.StartPos(field.Type), but we already have this as
field.Pos().)

Change-Id: If6ac9635b6e9c2b75a1989d5893a78e0b21cba88
Reviewed-on: https://go-review.googlesource.com/c/go/+/320611
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/typexpr.go

index e64d804c30b8ccc59a9c5532d714a624109c0cca..a1663d2aa0c4d70d6e9e9ee1905db319c7eaa556 100644 (file)
@@ -778,7 +778,7 @@ func (check *Checker) collectParams(scope *Scope, list []*syntax.Field, type0 sy
                        named = true
                } else {
                        // anonymous parameter
-                       par := NewParam(ftype.Pos(), check.pkg, "", typ)
+                       par := NewParam(field.Pos(), check.pkg, "", typ)
                        check.recordImplicit(field, par)
                        params = append(params, par)
                        anonymous = true