From 5e43856aa9c3d17c79688415b1347650d711744b Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 6 Sep 2019 12:26:57 -0700 Subject: [PATCH] cmd/compile: rename Etype to ctxType golang.org/cl/150140 renamed the other Efoo constants to ctxFoo, but forgot about Etype. gorename -from '"cmd/compile/internal/gc".Etype -to ctxType Change-Id: I142dd42ca84a398f8d2316d75ead3331c023b820 Reviewed-on: https://go-review.googlesource.com/c/go/+/193958 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder --- src/cmd/compile/internal/gc/closure.go | 2 +- src/cmd/compile/internal/gc/dcl.go | 6 +- src/cmd/compile/internal/gc/subr.go | 2 +- src/cmd/compile/internal/gc/swt.go | 8 +-- src/cmd/compile/internal/gc/typecheck.go | 72 ++++++++++++------------ 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go index 397162dac8..fb04924121 100644 --- a/src/cmd/compile/internal/gc/closure.go +++ b/src/cmd/compile/internal/gc/closure.go @@ -73,7 +73,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node { func typecheckclosure(clo *Node, top int) { xfunc := clo.Func.Closure - clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype) + clo.Func.Ntype = typecheck(clo.Func.Ntype, ctxType) clo.Type = clo.Func.Ntype.Type clo.Func.Top = top diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index 012f993d69..32b72a44d8 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -544,7 +544,7 @@ func structfield(n *Node) *types.Field { f.Sym = n.Sym if n.Left != nil { - n.Left = typecheck(n.Left, Etype) + n.Left = typecheck(n.Left, ctxType) n.Type = n.Left.Type n.Left = nil } @@ -668,7 +668,7 @@ func interfacefield(n *Node) *types.Field { // Otherwise, Left is InterfaceTypeName. if n.Left != nil { - n.Left = typecheck(n.Left, Etype) + n.Left = typecheck(n.Left, ctxType) n.Type = n.Left.Type n.Left = nil } @@ -1020,7 +1020,7 @@ func dclfunc(sym *types.Sym, tfn *Node) *Node { fn.Func.Nname.Name.Param.Ntype = tfn declare(fn.Func.Nname, PFUNC) funchdr(fn) - fn.Func.Nname.Name.Param.Ntype = typecheck(fn.Func.Nname.Name.Param.Ntype, Etype) + fn.Func.Nname.Name.Param.Ntype = typecheck(fn.Func.Nname.Name.Param.Ntype, ctxType) return fn } diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index dca9772ead..8c72a5928c 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -1286,7 +1286,7 @@ func dotpath(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) ( // will give shortest unique addressing. // modify the tree with missing type names. func adddot(n *Node) *Node { - n.Left = typecheck(n.Left, Etype|ctxExpr) + n.Left = typecheck(n.Left, ctxType|ctxExpr) if n.Left.Diag() { n.SetDiag(true) } diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go index 1436e29bae..33bc71b862 100644 --- a/src/cmd/compile/internal/gc/swt.go +++ b/src/cmd/compile/internal/gc/swt.go @@ -63,7 +63,7 @@ func typecheckswitch(n *Node) { if n.Left != nil && n.Left.Op == OTYPESW { // type switch - top = Etype + top = ctxType n.Left.Right = typecheck(n.Left.Right, ctxExpr) t = n.Left.Right.Type if t != nil && !t.IsInterface() { @@ -121,7 +121,7 @@ func typecheckswitch(n *Node) { ls := ncase.List.Slice() for i1, n1 := range ls { setlineno(n1) - ls[i1] = typecheck(ls[i1], ctxExpr|Etype) + ls[i1] = typecheck(ls[i1], ctxExpr|ctxType) n1 = ls[i1] if n1.Type == nil || t == nil { continue @@ -149,7 +149,7 @@ func typecheckswitch(n *Node) { } // type switch - case Etype: + case ctxType: var missing, have *types.Field var ptr int switch { @@ -183,7 +183,7 @@ func typecheckswitch(n *Node) { } } - if top == Etype { + if top == ctxType { ll := ncase.List if ncase.Rlist.Len() != 0 { nvar := ncase.Rlist.First() diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 5d5348fe2c..a18470ea98 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -58,7 +58,7 @@ func tracePrint(title string, n *Node) func(np **Node) { const ( ctxStmt = 1 << iota // evaluated at statement level ctxExpr // evaluated in value context - Etype // evaluated in type context + ctxType // evaluated in type context ctxCallee // call-only expressions are ok ctxMultiOK // multivalue function returns are ok ctxAssign // assigning to expression @@ -242,14 +242,14 @@ func typecheck(n *Node, top int) (res *Node) { switch n.Op { // We can already diagnose variables used as types. case ONAME: - if top&(ctxExpr|Etype) == Etype { + if top&(ctxExpr|ctxType) == ctxType { yyerror("%v is not a type", n) } case OTYPE: // Only report a type cycle if we are expecting a type. // Otherwise let other code report an error. - if top&Etype == Etype { + if top&ctxType == ctxType { // A cycle containing only alias types is an error // since it would expand indefinitely when aliases // are substituted. @@ -272,7 +272,7 @@ func typecheck(n *Node, top int) (res *Node) { } case OLITERAL: - if top&(ctxExpr|Etype) == Etype { + if top&(ctxExpr|ctxType) == ctxType { yyerror("%v is not a type", n) break } @@ -397,15 +397,15 @@ func typecheck1(n *Node, top int) (res *Node) { // types (ODEREF is with exprs) case OTYPE: - ok |= Etype + ok |= ctxType if n.Type == nil { return n } case OTARRAY: - ok |= Etype - r := typecheck(n.Right, Etype) + ok |= ctxType + r := typecheck(n.Right, ctxType) if r.Type == nil { n.Type = nil return n @@ -464,9 +464,9 @@ func typecheck1(n *Node, top int) (res *Node) { } case OTMAP: - ok |= Etype - n.Left = typecheck(n.Left, Etype) - n.Right = typecheck(n.Right, Etype) + ok |= ctxType + n.Left = typecheck(n.Left, ctxType) + n.Right = typecheck(n.Right, ctxType) l := n.Left r := n.Right if l.Type == nil || r.Type == nil { @@ -486,8 +486,8 @@ func typecheck1(n *Node, top int) (res *Node) { n.Right = nil case OTCHAN: - ok |= Etype - n.Left = typecheck(n.Left, Etype) + ok |= ctxType + n.Left = typecheck(n.Left, ctxType) l := n.Left if l.Type == nil { n.Type = nil @@ -502,16 +502,16 @@ func typecheck1(n *Node, top int) (res *Node) { n.ResetAux() case OTSTRUCT: - ok |= Etype + ok |= ctxType setTypeNode(n, tostruct(n.List.Slice())) n.List.Set(nil) case OTINTER: - ok |= Etype + ok |= ctxType setTypeNode(n, tointerface(n.List.Slice())) case OTFUNC: - ok |= Etype + ok |= ctxType setTypeNode(n, functype(n.Left, n.List.Slice(), n.Rlist.Slice())) n.Left = nil n.List.Set(nil) @@ -519,7 +519,7 @@ func typecheck1(n *Node, top int) (res *Node) { // type or expr case ODEREF: - n.Left = typecheck(n.Left, ctxExpr|Etype|top&ctxCompLit) + n.Left = typecheck(n.Left, ctxExpr|ctxType|top&ctxCompLit) l := n.Left t := l.Type if t == nil { @@ -527,7 +527,7 @@ func typecheck1(n *Node, top int) (res *Node) { return n } if l.Op == OTYPE { - ok |= Etype + ok |= ctxType setTypeNode(n, types.NewPtr(l.Type)) // Ensure l.Type gets dowidth'd for the backend. Issue 20174. // Don't checkwidth [...] arrays, though, since they @@ -876,7 +876,7 @@ func typecheck1(n *Node, top int) (res *Node) { } } - n.Left = typecheck(n.Left, ctxExpr|Etype) + n.Left = typecheck(n.Left, ctxExpr|ctxType) n.Left = defaultlit(n.Left, nil) @@ -969,7 +969,7 @@ func typecheck1(n *Node, top int) (res *Node) { } if n.Right != nil { - n.Right = typecheck(n.Right, Etype) + n.Right = typecheck(n.Right, ctxType) n.Type = n.Right.Type n.Right = nil if n.Type == nil { @@ -1235,7 +1235,7 @@ func typecheck1(n *Node, top int) (res *Node) { // call and call like case OCALL: typecheckslice(n.Ninit.Slice(), ctxStmt) // imported rewritten f(g()) calls (#30907) - n.Left = typecheck(n.Left, ctxExpr|Etype|ctxCallee) + n.Left = typecheck(n.Left, ctxExpr|ctxType|ctxCallee) if n.Left.Diag() { n.SetDiag(true) } @@ -1689,7 +1689,7 @@ func typecheck1(n *Node, top int) (res *Node) { n.List.Set(nil) l := args[0] - l = typecheck(l, Etype) + l = typecheck(l, ctxType) t := l.Type if t == nil { n.Type = nil @@ -1799,7 +1799,7 @@ func typecheck1(n *Node, top int) (res *Node) { } l := args.First() - l = typecheck(l, Etype) + l = typecheck(l, ctxType) t := l.Type if t == nil { n.Type = nil @@ -2034,7 +2034,7 @@ func typecheck1(n *Node, top int) (res *Node) { case ODCLTYPE: ok |= ctxStmt - n.Left = typecheck(n.Left, Etype) + n.Left = typecheck(n.Left, ctxType) checkwidth(n.Left.Type) if n.Left.Type != nil && n.Left.Type.NotInHeap() && n.Left.Name.Param.Pragma&NotInHeap == 0 { // The type contains go:notinheap types, so it @@ -2057,7 +2057,7 @@ func typecheck1(n *Node, top int) (res *Node) { } evconst(n) - if n.Op == OTYPE && top&Etype == 0 { + if n.Op == OTYPE && top&ctxType == 0 { if !n.Type.Broke() { yyerror("type %v is not an expression", n.Type) } @@ -2065,20 +2065,20 @@ func typecheck1(n *Node, top int) (res *Node) { return n } - if top&(ctxExpr|Etype) == Etype && n.Op != OTYPE { + if top&(ctxExpr|ctxType) == ctxType && n.Op != OTYPE { yyerror("%v is not a type", n) n.Type = nil return n } // TODO(rsc): simplify - if (top&(ctxCallee|ctxExpr|Etype) != 0) && top&ctxStmt == 0 && ok&(ctxExpr|Etype|ctxCallee) == 0 { + if (top&(ctxCallee|ctxExpr|ctxType) != 0) && top&ctxStmt == 0 && ok&(ctxExpr|ctxType|ctxCallee) == 0 { yyerror("%v used as value", n) n.Type = nil return n } - if (top&ctxStmt != 0) && top&(ctxCallee|ctxExpr|Etype) == 0 && ok&ctxStmt == 0 { + if (top&ctxStmt != 0) && top&(ctxCallee|ctxExpr|ctxType) == 0 && ok&ctxStmt == 0 { if !n.Diag() { yyerror("%v evaluated but not used", n) n.SetDiag(true) @@ -2475,11 +2475,11 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field { checklvalue(n.Left, "call pointer method on") n.Left = nod(OADDR, n.Left, nil) n.Left.SetImplicit(true) - n.Left = typecheck(n.Left, Etype|ctxExpr) + n.Left = typecheck(n.Left, ctxType|ctxExpr) } else if tt.IsPtr() && !rcvr.IsPtr() && types.Identical(tt.Elem(), rcvr) { n.Left = nod(ODEREF, n.Left, nil) n.Left.SetImplicit(true) - n.Left = typecheck(n.Left, Etype|ctxExpr) + n.Left = typecheck(n.Left, ctxType|ctxExpr) } else if tt.IsPtr() && tt.Elem().IsPtr() && types.Identical(derefall(tt), derefall(rcvr)) { yyerror("calling method %v with receiver %L requires explicit dereference", n.Sym, n.Left) for tt.IsPtr() { @@ -2489,7 +2489,7 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field { } n.Left = nod(ODEREF, n.Left, nil) n.Left.SetImplicit(true) - n.Left = typecheck(n.Left, Etype|ctxExpr) + n.Left = typecheck(n.Left, ctxType|ctxExpr) tt = tt.Elem() } } else { @@ -2753,7 +2753,7 @@ func pushtype(n *Node, t *types.Type) { n.SetImplicit(true) // don't print n.Right.SetImplicit(true) // * is okay } else if Debug['s'] != 0 { - n.Right = typecheck(n.Right, Etype) + n.Right = typecheck(n.Right, ctxType) if n.Right.Type != nil && types.Identical(n.Right.Type, t) { fmt.Printf("%v: redundant type: %v\n", n.Line(), t) } @@ -2782,7 +2782,7 @@ func typecheckcomplit(n *Node) (res *Node) { norig := n.copy() setlineno(n.Right) - n.Right = typecheck(n.Right, Etype|ctxCompLit) + n.Right = typecheck(n.Right, ctxType|ctxCompLit) l := n.Right // sic t := l.Type if t == nil { @@ -3497,7 +3497,7 @@ func typecheckdeftype(n *Node) { } n.SetTypecheck(1) - n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) + n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType) t := n.Name.Param.Ntype.Type if t == nil { n.SetDiag(true) @@ -3559,7 +3559,7 @@ func typecheckdef(n *Node) { case OLITERAL: if n.Name.Param.Ntype != nil { - n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) + n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType) n.Type = n.Name.Param.Ntype.Type n.Name.Param.Ntype = nil if n.Type == nil { @@ -3611,7 +3611,7 @@ func typecheckdef(n *Node) { case ONAME: if n.Name.Param.Ntype != nil { - n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) + n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType) n.Type = n.Name.Param.Ntype.Type if n.Type == nil { n.SetDiag(true) @@ -3651,7 +3651,7 @@ func typecheckdef(n *Node) { // to create a new type. // If we have a syntax error, p.Ntype may be nil. if p.Ntype != nil { - p.Ntype = typecheck(p.Ntype, Etype) + p.Ntype = typecheck(p.Ntype, ctxType) n.Type = p.Ntype.Type if n.Type == nil { n.SetDiag(true) -- 2.50.0