diff options
author | Rob Findley <rfindley@google.com> | 2021-02-24 10:31:11 -0500 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2021-03-02 01:50:12 +0000 |
commit | a6eeb4add46eddb19ceba36bdd448738808e5ce2 (patch) | |
tree | 06b2d25e5aef46c7ce3da6fae61e199025efdd88 /src/go/parser/interface.go | |
parent | ff5cf4ced3f1681ec972cd954d4b476f87616fe3 (diff) | |
download | go-a6eeb4add46eddb19ceba36bdd448738808e5ce2.tar.gz go-a6eeb4add46eddb19ceba36bdd448738808e5ce2.zip |
go/parser,go/types: hide API changes related to type parameters
While the dev.typeparams branch was merged, the type parameter API is
slated for go1.18. Hide these changes to the go/parser and go/types API.
This was done as follows:
+ For APIs that will probably not be needed for go1.18, simply unexport
them.
+ For APIs that we expect to export in go1.18, prefix symbols with '_',
so that the planned (upper-cased) symbol name is apparent.
+ For APIs that must be exported for testing, move both API and tests
to files guarded by the go1.18 build constraint.
+ parser.ParseTypeParams is unexported and copied wherever it is
needed.
+ The -G flag is removed from gofmt, replaced by enabling type
parameters if built with the go1.18 build constraint.
Notably, changes related to type parameters in go/ast are currently left
exported. We're looking at the AST API separately.
The new API diff from 1.16 is:
+pkg go/ast, method (*FuncDecl) IsMethod() bool
+pkg go/ast, method (*ListExpr) End() token.Pos
+pkg go/ast, method (*ListExpr) Pos() token.Pos
+pkg go/ast, type FuncType struct, TParams *FieldList
+pkg go/ast, type ListExpr struct
+pkg go/ast, type ListExpr struct, ElemList []Expr
+pkg go/ast, type TypeSpec struct, TParams *FieldList
+pkg go/types, type Config struct, GoVersion string
Change-Id: I1baf67e26279b49092e774309a836c460979774a
Reviewed-on: https://go-review.googlesource.com/c/go/+/295929
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>
Diffstat (limited to 'src/go/parser/interface.go')
-rw-r--r-- | src/go/parser/interface.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/go/parser/interface.go b/src/go/parser/interface.go index b8b312463f..123faaee77 100644 --- a/src/go/parser/interface.go +++ b/src/go/parser/interface.go @@ -55,8 +55,14 @@ const ( Trace // print a trace of parsed productions DeclarationErrors // report declaration errors SpuriousErrors // same as AllErrors, for backward-compatibility - ParseTypeParams // Placeholder. Will control the parsing of type parameters. AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines) + + // parseTypeParams controls the parsing of type parameters. Must be + // kept in sync with: + // go/printer/printer_test.go + // go/types/check_test.go + // cmd/gofmt/gofmt.go + parseTypeParams = 1 << 30 ) // ParseFile parses the source code of a single Go source file and returns |