@@ -1831,18 +1831,48 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
1831
1831
}
1832
1832
1833
1833
case ( ast. expr_send( ?lhs, ?rhs, _) ) {
1834
- auto checked = check_assignment_like( fcx, lhs, rhs) ;
1835
- auto newexpr = ast. expr_send( checked. _0,
1836
- checked. _1,
1837
- checked. _2) ;
1834
+ auto lhs_0 = check_expr( fcx, lhs) ;
1835
+ auto rhs_0 = check_expr( fcx, rhs) ;
1836
+ auto rhs_t = expr_ty( rhs_0) ;
1837
+
1838
+ auto chan_t = plain_ty( ty. ty_chan( rhs_t) ) ;
1839
+ auto lhs_1 = demand_expr( fcx, chan_t, lhs_0) ;
1840
+ auto item_t;
1841
+ alt ( expr_ty( lhs_1) . struct ) {
1842
+ case ( ty. ty_chan( ?it) ) {
1843
+ item_t = it;
1844
+ }
1845
+ case ( _) {
1846
+ fail;
1847
+ }
1848
+ }
1849
+ auto rhs_1 = demand_expr( fcx, item_t, rhs_0) ;
1850
+
1851
+ auto ann = ast. ann_type( chan_t, none[ vec[ @ty. t] ] ) ;
1852
+ auto newexpr = ast. expr_send( lhs_1, rhs_1, ann) ;
1838
1853
ret @fold. respan[ ast. expr_] ( expr. span, newexpr) ;
1839
1854
}
1840
1855
1841
1856
case ( ast. expr_recv( ?lhs, ?rhs, _) ) {
1842
- auto checked = check_assignment_like( fcx, lhs, rhs) ;
1843
- auto newexpr = ast. expr_recv( checked. _0,
1844
- checked. _1,
1845
- checked. _2) ;
1857
+ auto lhs_0 = check_expr( fcx, lhs) ;
1858
+ auto rhs_0 = check_expr( fcx, rhs) ;
1859
+ auto lhs_t1 = expr_ty( lhs_0) ;
1860
+
1861
+ auto port_t = plain_ty( ty. ty_port( lhs_t1) ) ;
1862
+ auto rhs_1 = demand_expr( fcx, port_t, rhs_0) ;
1863
+ auto item_t;
1864
+ alt ( expr_ty( rhs_0) . struct ) {
1865
+ case ( ty. ty_port( ?it) ) {
1866
+ item_t = it;
1867
+ }
1868
+ case ( _) {
1869
+ fail;
1870
+ }
1871
+ }
1872
+ auto lhs_1 = demand_expr( fcx, item_t, lhs_0) ;
1873
+
1874
+ auto ann = ast. ann_type( item_t, none[ vec[ @ty. t] ] ) ;
1875
+ auto newexpr = ast. expr_recv( lhs_1, rhs_1, ann) ;
1846
1876
ret @fold. respan[ ast. expr_] ( expr. span, newexpr) ;
1847
1877
}
1848
1878
0 commit comments