]> Cypherpunks repositories - gostls13.git/commit
go/parser: move type params in scope for the function signature
authorRob Findley <rfindley@google.com>
Thu, 25 Mar 2021 01:55:49 +0000 (21:55 -0400)
committerRobert Findley <rfindley@google.com>
Fri, 16 Apr 2021 21:19:23 +0000 (21:19 +0000)
commit9e8a312b71b3ad271026947d15f4d9fc483b0132
treee10c81805941b64e0c1c4143c9e793e11cc982c7
parent13368ab56a75134910e70db4bc0e2860e6a97829
go/parser: move type params in scope for the function signature

Type parameter resolution is a bit tricky: type parameters are in the
function scope, but unlike ordinary parameters may reference eachother.
When resolving the function scope, we must be careful about the order in
which objects are resolved and declared.

Using ordering allows us to avoid passing around temporary scopes for
field declarations.

Add a bunch of tests for this behavior, and skip "_" in resolution tests
as it just adds noise.

For #45221

Change-Id: Id080cddce3fd76396bf86ba5aba856aedf64a458
Reviewed-on: https://go-review.googlesource.com/c/go/+/304456
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/parser/resolver.go
src/go/parser/resolver_test.go
src/go/parser/testdata/resolution/issue45136.src
src/go/parser/testdata/resolution/issue45160.src
src/go/parser/testdata/resolution/resolution.src
src/go/parser/testdata/resolution/typeparams.go2