summaryrefslogtreecommitdiff
path: root/src/go/parser/resolver_test.go
Commit message (Collapse)AuthorAgeFilesLines
* go/parser: remove (internal) ability to disable generic codeRobert Griesemer2022-08-191-4/+0
| | | | | | | | | | | | | Generics are part of the language now; there's no need anymore to switch back to a syntax without generics. Remove the associated machinery and adjust short tests accordingly. Change-Id: I6b16c5c75fd9354ee87e3b9bee110f49f514565a Reviewed-on: https://go-review.googlesource.com/c/go/+/424857 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
* [dev.typeparams] go/internal/typeparams: remove the Enabled guardRob Findley2021-07-161-5/+1
| | | | | | | | | | | | | | Type parameters are now always enabled. Users should guard against type checking generic code by using the types.Config.GoVersion field. This cleans up some differences with types2. Change-Id: Ie3e35a549e456a90a10d6a7e158ff58653cc1394 Reviewed-on: https://go-review.googlesource.com/c/go/+/335033 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
* go/parser: move type params in scope for the function signatureRob Findley2021-04-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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>
* go/*,cmd/gofmt: guard AST changes with the typeparams build tagRob Findley2021-04-131-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes our approach to guarding type parameter functionality and API. Previously, we guarded type parameter functionality with the parser.parseTypeParams parser mode, and were in the process of hiding the type parameter API behind the go1.18 build constraint. These mechanisms had several limitations: + Requiring the parser.parseTypeParams mode to be set meant that existing tooling would have to opt-in to type parameters in all places where it parses Go files. + The parseTypeParams mode value had to be copied in several places. + go1.18 is not specific to typeparams, making it difficult to set up the builders to run typeparams tests. This CL addresses the above limitations, and completes the task of hiding the AST API, by switching to a new 'typeparams' build constraint and adding a new go/internal/typeparams helper package. The typeparams build constraint is used to conditionally compile the new AST changes. The typeparams package provides utilities for accessing and writing the new AST data, so that we don't have to fragment our parser or type checker logic across build constraints. The typeparams.Enabled const is used to guard tests that require type parameter support. The parseTypeParams parser mode is gone, replaced by a new typeparams.DisableParsing mode with the opposite sense. Now, type parameters are only parsed if go/parser is compiled with the typeparams build constraint set AND typeparams.DisableParsing not set. This new parser mode allows opting out of type parameter parsing for tests. How exactly to run tests on builders is left to a follow-up CL. Updates #44933 Change-Id: I3091e42a2e5e2f23e8b2ae584f415a784b9fbd65 Reviewed-on: https://go-review.googlesource.com/c/go/+/300649 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
* go/parser: add resolution tests for type paramsRob Findley2021-03-311-1/+5
| | | | | | | | | | | | | For #45104 For #45221 Change-Id: I8966555f4e8844d5b6766d00d48f7a81868ccf40 Reviewed-on: https://go-review.googlesource.com/c/go/+/304453 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>
* go/parser: add data-driven tests for object resolutionRob Findley2021-03-301-0/+170
Add new tests for object resolution driven by source files with declarations and uses marked via special comments. This made it easier to add test coverage while refactoring object resolution for #45104. Tests are added to a new resolver_test.go file. In a subsequent CL the resolver.go file will be added, making this choice of file name more sensible. For #45104 For #45136 For #45160 Change-Id: I240fccc0de95aa8f2d03e39c77146d4c61f1ef9e Reviewed-on: https://go-review.googlesource.com/c/go/+/304450 Trust: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>