From 2aea44204ef8e3467bd2d21865e3d2b8045f3d12 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 1 Jul 2021 12:47:58 -0700 Subject: [dev.typeparams] cmd/compile: enable generics syntax with -lang=go1.18 We already use -lang=go1.18 to control the types2 type checker behavior. This CL does the same for the parser. Also, disable an assertion in the unified IR linker that depended on the -G flag. This assertion was more useful during initial bootstrapping of that code, but it's less critical now. With these two changes, "GOEXPERIMENT=unified ./make.bash" is enough to get a fully functional generics-enabled toolchain. There's no need to continue specifying custom compiler flags later on. Change-Id: I7766381926f3bb17eee2e5fcc182a38a39e937e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/332373 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Trust: Matthew Dempsky Trust: Robert Griesemer Reviewed-by: Robert Griesemer Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/noder/noder.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/noder/noder.go') diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index 3d83129aea..6a2aacd3fe 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -9,6 +9,7 @@ import ( "fmt" "go/constant" "go/token" + "internal/buildcfg" "os" "path/filepath" "runtime" @@ -30,8 +31,11 @@ import ( func LoadPackage(filenames []string) { base.Timer.Start("fe", "parse") + // -G=3 and unified expect generics syntax, but -G=0 does not. + supportsGenerics := base.Flag.G != 0 || buildcfg.Experiment.Unified + mode := syntax.CheckBranches - if base.Flag.G != 0 { + if supportsGenerics && types.AllowsGoVersion(types.LocalPkg, 1, 18) { mode |= syntax.AllowGenerics } -- cgit v1.2.3-54-g00ecf