aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/helpers.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-03-13 22:41:51 -0800
committerDan Scales <danscales@google.com>2021-03-15 20:28:10 +0000
commitdca9c11845a950130c37f4f4e5ffb55848ff7155 (patch)
tree012cba401bfd2e79a9f9b08cf87d485dd849fd6a /src/cmd/compile/internal/noder/helpers.go
parentbd6aeca9686d5e672ffda1ea0cfeac7a3e7a20a4 (diff)
downloadgo-dca9c11845a950130c37f4f4e5ffb55848ff7155.tar.xz
cmd/compile: add support for generic channels and type conversion during calls
Add support for channels in subster.typ(). Add new test file chans.go. To support assignability of bidirectional channel args to directional channel params, I needed to type check generic calls after they are instantiated. (Eventually, we will create separate functions to just do the assignability logic, so we don't need to call the old typechecker in this case.) So, for generic calls, we now leave the call as OCALL (as a signal that the call still needs typechecking), and do typecheck.Call() during stenciling. Smaller changes: - Set the type of an instantiated OCLOSURE node (and not just the associated OFUNC node) - In instTypeName2, filter out the space that types2.TypeString inserts after a common in a typelist. Our standard naming requires no space after the comma. - With the assignability fix above, I no longer need the explicit conversions in cons.go. Change-Id: I148858bfc6708c0aa3f50bad7debce2b8c8c091f Reviewed-on: https://go-review.googlesource.com/c/go/+/301669 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/helpers.go')
-rw-r--r--src/cmd/compile/internal/noder/helpers.go21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go
index 2b084ff311..cf7a3e22b3 100644
--- a/src/cmd/compile/internal/noder/helpers.go
+++ b/src/cmd/compile/internal/noder/helpers.go
@@ -138,30 +138,19 @@ func Call(pos src.XPos, typ *types.Type, fun ir.Node, args []ir.Node, dots bool)
return n
}
if fun.Op() != ir.OFUNCINST {
- // If no type params, still do normal typechecking, since we're
- // still missing some things done by tcCall below (mainly
- // typecheckargs and typecheckaste).
+ // If no type params, do normal typechecking, since we're
+ // still missing some things done by tcCall (mainly
+ // typecheckaste/assignconvfn - implementing assignability of args
+ // to params). This will convert OCALL to OCALLFUNC.
typecheck.Call(n)
return n
}
+ // Leave the op as OCALL, which indicates the call still needs typechecking.
n.Use = ir.CallUseExpr
if fun.Type().NumResults() == 0 {
n.Use = ir.CallUseStmt
}
-
- // Rewrite call node depending on use.
- switch fun.Op() {
- case ir.ODOTINTER:
- n.SetOp(ir.OCALLINTER)
-
- case ir.ODOTMETH:
- n.SetOp(ir.OCALLMETH)
-
- default:
- n.SetOp(ir.OCALLFUNC)
- }
-
typed(typ, n)
return n
}