diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 42f2ddd5dda0e..0e8fee7719024 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -2341,7 +2341,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { let _icx = bcx.insn_ctxt("trans_callee"); alt e.node { ast::expr_path(path) { ret trans_path(bcx, e.id); } - ast::expr_field(base, ident, _) { + ast::expr_field(base, _, _) { // Lval means this is a record field, so not a method if !expr_is_lval(bcx, e) { alt bcx.ccx().maps.method_map.find(e.id) { diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index fe545a9a4fd92..cb87000c7c61b 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -95,13 +95,15 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, } } -fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id) -> uint { +fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, + i_id: ast::def_id) -> uint { if m_id.crate == ast::local_crate { alt check ccx.tcx.items.get(m_id.node) { ast_map::node_method(m, _, _) { vec::len(m.tps) } } } else { - csearch::get_type_param_count(ccx.sess.cstore, m_id) + csearch::get_type_param_count(ccx.sess.cstore, m_id) - + csearch::get_type_param_count(ccx.sess.cstore, i_id) } } @@ -115,7 +117,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, let ccx = bcx.ccx(); let mname = ty::iface_methods(ccx.tcx, iface_id)[n_method].ident; let mth_id = method_with_name(bcx.ccx(), impl_did, mname); - let n_m_tps = method_ty_param_count(ccx, mth_id); + let n_m_tps = method_ty_param_count(ccx, mth_id, impl_did); let node_substs = node_id_type_params(bcx, callee_id); let ty_substs = impl_substs + vec::tailn(node_substs, node_substs.len() - n_m_tps); diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs new file mode 100644 index 0000000000000..8abe0f51ca7f0 --- /dev/null +++ b/src/test/run-pass/issue-2185.rs @@ -0,0 +1,9 @@ +import iter::*; + +fn main() { + let range = bind uint::range(0u, 1000u, _); + let filt = bind iter::filter(range, {|&&n: uint| n % 3u != 0u && n % 5u != 0u }, _); + let sum = iter::foldl(filt, 0u) {|accum, &&n: uint| accum + n }; + + io::println(#fmt("%u", sum)); +} \ No newline at end of file