mirror of https://github.com/golang/go.git
go/types: generate mono.go from types2 source
This CL reduces the amount of code that needs to be maintained manually by about 340 LOC. Change-Id: If7b96c30e5a2f1ff28ebf4ca2f3ac3f73d6a8865 Reviewed-on: https://go-review.googlesource.com/c/go/+/565839 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
96e9838f39
commit
ff8a2c0ad9
|
|
@ -150,9 +150,9 @@ func (check *Checker) reportInstanceLoop(v int) {
|
|||
default:
|
||||
panic("unexpected type")
|
||||
case *Named:
|
||||
err.addf(edge.pos, "%s implicitly parameterized by %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
|
||||
err.addf(atPos(edge.pos), "%s implicitly parameterized by %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
|
||||
case *TypeParam:
|
||||
err.addf(edge.pos, "%s instantiated as %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
|
||||
err.addf(atPos(edge.pos), "%s instantiated as %s", obj.Name(), TypeString(edge.typ, qf)) // secondary error, \t indented
|
||||
}
|
||||
}
|
||||
err.report()
|
||||
|
|
@ -173,7 +173,7 @@ func (w *monoGraph) recordInstance(pkg *Package, pos syntax.Pos, tparams []*Type
|
|||
for i, tpar := range tparams {
|
||||
pos := pos
|
||||
if i < len(xlist) {
|
||||
pos = syntax.StartPos(xlist[i])
|
||||
pos = startPos(xlist[i])
|
||||
}
|
||||
w.assign(pkg, pos, tpar, targs[i])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ func argErrPos(call *syntax.CallExpr) *syntax.CallExpr { return call }
|
|||
// ExprString returns a string representation of x.
|
||||
func ExprString(x syntax.Node) string { return syntax.String(x) }
|
||||
|
||||
// startPos returns the start position of node n.
|
||||
func startPos(n syntax.Node) syntax.Pos { return syntax.StartPos(n) }
|
||||
|
||||
// endPos returns the position of the first character immediately after node n.
|
||||
func endPos(n syntax.Node) syntax.Pos { return syntax.EndPos(n) }
|
||||
|
||||
|
|
|
|||
|
|
@ -133,10 +133,15 @@ var filemap = map[string]action{
|
|||
"lookup.go": func(f *ast.File) { fixTokenPos(f) },
|
||||
"main_test.go": nil,
|
||||
"map.go": nil,
|
||||
"named.go": func(f *ast.File) { fixTokenPos(f); renameSelectors(f, "Trace->_Trace") },
|
||||
"object.go": func(f *ast.File) { fixTokenPos(f); renameIdents(f, "NewTypeNameLazy->_NewTypeNameLazy") },
|
||||
"object_test.go": func(f *ast.File) { renameImportPath(f, `"cmd/compile/internal/types2"->"go/types"`) },
|
||||
"objset.go": nil,
|
||||
"mono.go": func(f *ast.File) {
|
||||
fixTokenPos(f)
|
||||
insertImportPath(f, `"go/ast"`)
|
||||
renameSelectorExprs(f, "syntax.Expr->ast.Expr")
|
||||
},
|
||||
"named.go": func(f *ast.File) { fixTokenPos(f); renameSelectors(f, "Trace->_Trace") },
|
||||
"object.go": func(f *ast.File) { fixTokenPos(f); renameIdents(f, "NewTypeNameLazy->_NewTypeNameLazy") },
|
||||
"object_test.go": func(f *ast.File) { renameImportPath(f, `"cmd/compile/internal/types2"->"go/types"`) },
|
||||
"objset.go": nil,
|
||||
"operand.go": func(f *ast.File) {
|
||||
insertImportPath(f, `"go/token"`)
|
||||
renameImportPath(f, `"cmd/compile/internal/syntax"->"go/ast"`)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
|
||||
|
||||
// Copyright 2021 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.
|
||||
|
|
@ -174,7 +176,7 @@ func (w *monoGraph) recordInstance(pkg *Package, pos token.Pos, tparams []*TypeP
|
|||
for i, tpar := range tparams {
|
||||
pos := pos
|
||||
if i < len(xlist) {
|
||||
pos = xlist[i].Pos()
|
||||
pos = startPos(xlist[i])
|
||||
}
|
||||
w.assign(pkg, pos, tpar, targs[i])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ func dddErrPos(call *ast.CallExpr) positioner { return atPos(call.Ellipsis) }
|
|||
// argErrPos returns positioner for reportign an invalid argument count.
|
||||
func argErrPos(call *ast.CallExpr) positioner { return inNode(call, call.Rparen) }
|
||||
|
||||
// startPos returns the start position of node n.
|
||||
func startPos(n ast.Node) token.Pos { return n.Pos() }
|
||||
|
||||
// endPos returns the position of the first character immediately after node n.
|
||||
func endPos(n ast.Node) token.Pos { return n.End() }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue