Skip to content

Commit

Permalink
Fix broken determination of external method type param count
Browse files Browse the repository at this point in the history
marijnh committed Apr 23, 2012

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5129275 commit dfdca5d
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
@@ -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) {
8 changes: 5 additions & 3 deletions src/rustc/middle/trans/impl.rs
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 9 additions & 0 deletions src/test/run-pass/issue-2185.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit dfdca5d

Please sign in to comment.