From 7b2f81eb3b19232c1d3a60241cb92c1c50d0e4ab Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 18 Aug 2023 01:14:50 -0700 Subject: [PATCH] cmd/compile/internal/typecheck: remove NeedRuntimeType The only remaining use for typecheck.NeedRuntimeType is to make sure that method expressions with anonymous receiver types (e.g., "struct{T}.M") have the promoted-method wrapper generated. But the unified frontend takes care of arranging for this now. Change-Id: I89340cb6a81343f35e0de1062610cbb993d3b6bf Reviewed-on: https://go-review.googlesource.com/c/go/+/521036 Run-TryBot: Matthew Dempsky Reviewed-by: Cuong Manh Le Auto-Submit: Matthew Dempsky Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot --- src/cmd/compile/internal/gc/main.go | 2 -- src/cmd/compile/internal/typecheck/typecheck.go | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index ae695b58f9..c8f1dae728 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -186,8 +186,6 @@ func Main(archInit func(*ssagen.ArchInfo)) { typecheck.Target = new(ir.Package) - typecheck.NeedRuntimeType = reflectdata.NeedRuntimeType // TODO(rsc): TypeSym for lock? - base.AutogeneratedPos = makePos(src.NewFileBase("", ""), 1, 0) typecheck.InitUniverse() diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index 384295b55f..92a907fec9 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -20,10 +20,6 @@ import ( // to be included in the package-level init function. var InitTodoFunc = ir.NewFunc(base.Pos, base.Pos, Lookup("$InitTodo"), types.NewSignature(nil, nil, nil)) -var ( - NeedRuntimeType = func(*types.Type) {} -) - func AssignExpr(n ir.Node) ir.Node { return typecheck(n, ctxExpr|ctxAssign) } func Expr(n ir.Node) ir.Node { return typecheck(n, ctxExpr) } func Stmt(n ir.Node) ir.Node { return typecheck(n, ctxStmt) } @@ -869,17 +865,6 @@ func typecheckMethodExpr(n *ir.SelectorExpr) (res ir.Node) { } CalcMethods(mt) ms = mt.AllMethods() - - // The method expression T.m requires a wrapper when T - // is different from m's declared receiver type. We - // normally generate these wrappers while writing out - // runtime type descriptors, which is always done for - // types declared at package scope. However, we need - // to make sure to generate wrappers for anonymous - // receiver types too. - if mt.Sym() == nil { - NeedRuntimeType(t) - } } s := n.Sel