From e3f30831134b8767aeed00a356eda9087b52aeba Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 4 Sep 2024 16:37:45 -0700 Subject: [PATCH] go/types: generate literals.go from corresponding types2 source Change-Id: I0635101b984725ee24c2207ebfdb413d29212b67 Reviewed-on: https://go-review.googlesource.com/c/go/+/610558 Reviewed-by: Tim King Auto-Submit: Robert Griesemer Reviewed-by: Robert Griesemer LUCI-TryBot-Result: Go LUCI --- src/go/types/generate_test.go | 12 +++++++++--- src/go/types/literals.go | 9 +++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/go/types/generate_test.go b/src/go/types/generate_test.go index de2e63d163bf2e..1422d1ae7c5e93 100644 --- a/src/go/types/generate_test.go +++ b/src/go/types/generate_test.go @@ -136,9 +136,15 @@ var filemap = map[string]action{ // "initorder.go": fixErrErrorfCall, // disabled for now due to unresolved error_ use implications for gopls "instantiate.go": func(f *ast.File) { fixTokenPos(f); fixCheckErrorfCall(f) }, "instantiate_test.go": func(f *ast.File) { renameImportPath(f, `"cmd/compile/internal/types2"->"go/types"`) }, - "lookup.go": func(f *ast.File) { fixTokenPos(f) }, - "main_test.go": nil, - "map.go": nil, + "literals.go": func(f *ast.File) { + renameImportPath(f, `"cmd/compile/internal/syntax"->"go/ast"`) + renameSelectorExprs(f, "syntax.Name->ast.Ident", "key.Value->key.Name", "atyp.Elem->atyp.Elt") // must happen before renaming identifiers + renameIdents(f, "syntax->ast") + renameSelectors(f, "ElemList->Elts") + }, + "lookup.go": func(f *ast.File) { fixTokenPos(f) }, + "main_test.go": nil, + "map.go": nil, "mono.go": func(f *ast.File) { fixTokenPos(f) insertImportPath(f, `"go/ast"`) diff --git a/src/go/types/literals.go b/src/go/types/literals.go index d2bd7b5d15c5a1..a32f8ca37cb7e8 100644 --- a/src/go/types/literals.go +++ b/src/go/types/literals.go @@ -1,3 +1,6 @@ +// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT. +// Source: ../../cmd/compile/internal/types2/literals.go + // Copyright 2024 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -81,7 +84,7 @@ func (check *Checker) compositeLit(T *target, x *operand, e *ast.CompositeLit, h check.errorf(kv, InvalidLitField, "invalid field name %s in struct literal", kv.Key) continue } - i := fieldIndex(utyp.fields, check.pkg, key.Name, false) + i := fieldIndex(fields, check.pkg, key.Name, false) if i < 0 { var alt Object if j := fieldIndex(fields, check.pkg, key.Name, true); j >= 0 { @@ -117,9 +120,7 @@ func (check *Checker) compositeLit(T *target, x *operand, e *ast.CompositeLit, h // i < len(fields) fld := fields[i] if !fld.Exported() && fld.pkg != check.pkg { - check.errorf(x, - UnexportedLitField, - "implicit assignment to unexported field %s in struct literal of type %s", fld.name, base) + check.errorf(x, UnexportedLitField, "implicit assignment to unexported field %s in struct literal of type %s", fld.name, base) continue } etyp := fld.typ