@@ -1287,25 +1287,14 @@ impl exprFormatter {
12871287 }
12881288
12891289 fn chanType(&self, mut c: &ast::ChanType) {
1290- mut range := false
1291- if c.Recv && c.Send {
1290+ if c.Dir&(ast::RECV|ast::SEND) == ast::RECV|ast::SEND {
12921291 self.write("chan ")
1293- valueChan, isChan := c.Value.Data.(&ast::ChanType)
1294- if isChan {
1295- if valueChan.Recv && !valueChan.Send {
1296- range = true
1297- self.write("(")
1298- }
1299- }
1300- } else if c.Recv {
1292+ } else if c.Dir&ast::RECV == ast::RECV {
13011293 self.write("<-chan ")
13021294 } else {
13031295 self.write("chan<- ")
13041296 }
1305- self.formatKind(c.Value.Data)
1306- if range {
1307- self.write(")")
1308- }
1297+ self.format(c.Value)
13091298 }
13101299
13111300 fn lit(&self, l: &ast::LitExpr) {
@@ -1354,19 +1343,6 @@ impl exprFormatter {
13541343 self.write("...")
13551344 }
13561345
1357- fn cast(&self, mut c: &ast::CastExpr) {
1358- if isPrimType(c.Type) {
1359- self.fmt.formatType(c.Type)
1360- } else {
1361- self.write("(")
1362- self.fmt.formatType(c.Type)
1363- self.write(")")
1364- }
1365- self.write("(")
1366- self.format(c.X)
1367- self.write(")")
1368- }
1369-
13701346 fn namespace(&self, ns: &ast::NamespaceExpr) {
13711347 self.write(ns.Namespace.Kind)
13721348 self.write("::")
@@ -1530,11 +1506,6 @@ impl exprFormatter {
15301506 self.write("]")
15311507 }
15321508
1533- fn chanRecv(&self, mut c: &ast::ChanRecv) {
1534- self.write("<-")
1535- self.format(c.X)
1536- }
1537-
15381509 fn chanSend(&self, mut c: &ast::ChanSend) {
15391510 self.fmt.formatExpr(c.Chan)
15401511 self.write(" <- ")
@@ -1571,8 +1542,6 @@ impl exprFormatter {
15711542 self.unary(kind.(&ast::UnaryExpr))
15721543 | &ast::VariadicExpr:
15731544 self.variadic(kind.(&ast::VariadicExpr))
1574- | &ast::CastExpr:
1575- self.cast(kind.(&ast::CastExpr))
15761545 | &ast::NamespaceExpr:
15771546 self.namespace(kind.(&ast::NamespaceExpr))
15781547 | &ast::SelectorExpr:
@@ -1597,8 +1566,6 @@ impl exprFormatter {
15971566 self.write("[ ... ]")
15981567 | &ast::SlicingExpr:
15991568 self.slicing(kind.(&ast::SlicingExpr))
1600- | &ast::ChanRecv:
1601- self.chanRecv(kind.(&ast::ChanRecv))
16021569 | &ast::ChanSend:
16031570 self.chanSend(kind.(&ast::ChanSend))
16041571 | &ast::TypeAssertionExpr:
@@ -1819,8 +1786,7 @@ impl binaryFormatter {
18191786 | &ast::BinaryExpr:
18201787 // keep prec mode for tail
18211788 break
1822- | &ast::CallExpr
1823- | &ast::CastExpr:
1789+ | &ast::CallExpr:
18241790 self.zip = true
18251791
18261792 // disable prec mode for non-tail expressions
0 commit comments