cmd/compile: give ChanDir a type

Change-Id: I03621db79637b04982e1f0e7b4268c4ed2db6d22
Reviewed-on: https://go-review.googlesource.com/21484
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Brad Fitzpatrick 2016-04-03 22:58:10 +00:00
parent 73edd7b208
commit 386c0e6598
8 changed files with 27 additions and 21 deletions

View file

@ -1187,17 +1187,17 @@ func (p *parser) uexpr() *Node {
if x.Op == OTCHAN {
// x is a channel type => re-associate <-
dir := EType(Csend)
dir := Csend
t := x
for ; t.Op == OTCHAN && dir == Csend; t = t.Left {
dir = t.Etype
dir = ChanDir(t.Etype)
if dir == Crecv {
// t is type <-chan E but <-<-chan E is not permitted
// (report same error as for "type _ <-<-chan E")
p.syntax_error("unexpected <-, expecting chan")
// already progressed, no need to advance
}
t.Etype = Crecv
t.Etype = EType(Crecv)
}
if dir == Csend {
// channel dir is <- but channel element E is not a channel
@ -1697,7 +1697,7 @@ func (p *parser) try_ntype() *Node {
p.next()
p.want(LCHAN)
t := Nod(OTCHAN, p.chan_elem(), nil)
t.Etype = Crecv
t.Etype = EType(Crecv)
return t
case LFUNC:
@ -1726,9 +1726,9 @@ func (p *parser) try_ntype() *Node {
// LCHAN non_recvchantype
// LCHAN LCOMM ntype
p.next()
var dir EType = Cboth
var dir = EType(Cboth)
if p.got(LCOMM) {
dir = Csend
dir = EType(Csend)
}
t := Nod(OTCHAN, p.chan_elem(), nil)
t.Etype = dir