aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/noder.go2
-rw-r--r--src/cmd/compile/internal/noder/stencil.go27
-rw-r--r--src/cmd/compile/internal/noder/types.go24
3 files changed, 25 insertions, 28 deletions
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
index 2b67a91b3f..e1b485b2b3 100644
--- a/src/cmd/compile/internal/noder/noder.go
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -35,7 +35,7 @@ func LoadPackage(filenames []string) {
supportsGenerics := base.Flag.G != 0 || buildcfg.Experiment.Unified
mode := syntax.CheckBranches
- if supportsGenerics && types.AllowsGoVersion(types.LocalPkg, 1, 18) {
+ if supportsGenerics {
mode |= syntax.AllowGenerics
}
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go
index 602e88c102..b3ff4b8855 100644
--- a/src/cmd/compile/internal/noder/stencil.go
+++ b/src/cmd/compile/internal/noder/stencil.go
@@ -732,21 +732,15 @@ func (g *irgen) genericSubst(newsym *types.Sym, nameNode *ir.Name, shapes []*typ
g.instTypeList = append(g.instTypeList, subst.ts.InstTypeList...)
if doubleCheck {
- okConvs := map[ir.Node]bool{}
ir.Visit(newf, func(n ir.Node) {
- if n.Op() == ir.OIDATA {
- // IDATA(OCONVIFACE(x)) is ok, as we don't use the type of x.
- // TODO: use some other op besides OCONVIFACE. ONEW might work
- // (with appropriate direct vs. indirect interface cases).
- okConvs[n.(*ir.UnaryExpr).X] = true
+ if n.Op() != ir.OCONVIFACE {
+ return
}
- if n.Op() == ir.OCONVIFACE && !okConvs[n] {
- c := n.(*ir.ConvExpr)
- if c.X.Type().HasShape() {
- ir.Dump("BAD FUNCTION", newf)
- ir.Dump("BAD CONVERSION", c)
- base.Fatalf("converting shape type to interface")
- }
+ c := n.(*ir.ConvExpr)
+ if c.X.Type().HasShape() {
+ ir.Dump("BAD FUNCTION", newf)
+ ir.Dump("BAD CONVERSION", c)
+ base.Fatalf("converting shape type to interface")
}
})
}
@@ -1054,6 +1048,13 @@ func (subst *subster) node(n ir.Node) ir.Node {
case ir.OCLOSURE:
transformCall(call)
+ case ir.ODEREF, ir.OINDEX, ir.OINDEXMAP, ir.ORECV:
+ // Transform a call that was delayed because of the
+ // use of typeparam inside an expression that required
+ // a pointer dereference, array indexing, map indexing,
+ // or channel receive to compute function value.
+ transformCall(call)
+
case ir.OFUNCINST:
// A call with an OFUNCINST will get transformed
// in stencil() once we have created & attached the
diff --git a/src/cmd/compile/internal/noder/types.go b/src/cmd/compile/internal/noder/types.go
index 541ed68ef3..c9f7c2bbe4 100644
--- a/src/cmd/compile/internal/noder/types.go
+++ b/src/cmd/compile/internal/noder/types.go
@@ -30,21 +30,11 @@ func (g *irgen) pkg(pkg *types2.Package) *types.Pkg {
// typ converts a types2.Type to a types.Type, including caching of previously
// translated types.
func (g *irgen) typ(typ types2.Type) *types.Type {
+ // Defer the CheckSize calls until we have fully-defined a
+ // (possibly-recursive) top-level type.
+ types.DeferCheckSize()
res := g.typ1(typ)
-
- // Calculate the size for all concrete types seen by the frontend. The old
- // typechecker calls CheckSize() a lot, and we want to eliminate calling
- // it eventually, so we should do it here instead. We only call it for
- // top-level types (i.e. we do it here rather in typ1), to make sure that
- // recursive types have been fully constructed before we call CheckSize.
- if res != nil && !res.IsUntyped() && !res.IsFuncArgStruct() && !res.HasTParam() {
- types.CheckSize(res)
- if res.IsPtr() {
- // Pointers always have their size set, even though their element
- // may not have its size set.
- types.CheckSize(res.Elem())
- }
- }
+ types.ResumeCheckSize()
return res
}
@@ -59,6 +49,12 @@ func (g *irgen) typ1(typ types2.Type) *types.Type {
res, ok := g.typs[typ]
if !ok {
res = g.typ0(typ)
+ // Calculate the size for all concrete types seen by the frontend.
+ // This is the replacement for the CheckSize() calls in the types1
+ // typechecker. These will be deferred until the top-level g.typ().
+ if res != nil && !res.IsUntyped() && !res.IsFuncArgStruct() && !res.HasTParam() {
+ types.CheckSize(res)
+ }
g.typs[typ] = res
}
return res