mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: directly set some simple expression types
This CL updates irgen to directly set the type for a bunch of basic expressions that are easy to handle already. Trickier rewrites are still handled with typecheck.Expr, but responsibility of calling that is pushed down to the conversion of individual operations. Change-Id: I774ac6ab4c72ad854860ab5c741867dd42a066b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/285058 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
455c29af83
commit
2427f6e6c0
5 changed files with 90 additions and 39 deletions
|
|
@ -100,6 +100,9 @@ func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
|
|||
return
|
||||
}
|
||||
|
||||
// Prevent size calculations until we set the underlying type.
|
||||
types.DeferCheckSize()
|
||||
|
||||
name, obj := g.def(decl.Name)
|
||||
ntyp, otyp := name.Type(), obj.Type()
|
||||
if ir.CurFunc != nil {
|
||||
|
|
@ -135,6 +138,7 @@ func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
|
|||
// [mdempsky: Subtleties like these are why I always vehemently
|
||||
// object to new type pragmas.]
|
||||
ntyp.SetUnderlying(g.typeExpr(decl.Type))
|
||||
types.ResumeCheckSize()
|
||||
|
||||
if otyp, ok := otyp.(*types2.Named); ok && otyp.NumMethods() != 0 {
|
||||
methods := make([]*types.Field, otyp.NumMethods())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue