From 4e88d5ae92af1ebfb1d23e027db7133c669cca69 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 3 Jan 2012 16:37:41 +0100 Subject: Make resolution of dictionaries on bounded params work Issue #1227 --- src/comp/middle/trans_impl.rs | 4 +++- src/comp/middle/typeck.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/comp/middle') diff --git a/src/comp/middle/trans_impl.rs b/src/comp/middle/trans_impl.rs index aab8aaf10fa..7bcd2f6d880 100644 --- a/src/comp/middle/trans_impl.rs +++ b/src/comp/middle/trans_impl.rs @@ -147,6 +147,8 @@ fn get_dict(bcx: @block_ctxt, origin: typeck::dict_origin) -> result { } rslt(bcx, PointerCast(bcx, dict, T_ptr(T_dict()))) } - typeck::dict_param(_param) { fail "FIXME[impl]"; } + typeck::dict_param(n_param, n_bound) { + rslt(bcx, option::get(bcx.fcx.lltyparams[n_param].dicts)[n_bound]) + } } } \ No newline at end of file diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 662516141dc..f5b6f0f736a 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1515,10 +1515,10 @@ fn lookup_method(fcx: @fn_ctxt, isc: resolve::iscopes, } _ {} } + bound_n += 1u; } _ {} } - bound_n += 1u; } ret none; } @@ -2868,7 +2868,8 @@ fn check_for_main_fn(tcx: ty::ctxt, crate: @ast::crate) { type dict_res = @[dict_origin]; tag dict_origin { dict_static(ast::def_id, [ty::t], dict_res); - dict_param(uint); + // Param number, bound number + dict_param(uint, uint); } type dict_map = hashmap; @@ -2882,7 +2883,7 @@ fn resolve_dicts(tcx: ty::ctxt, impl_map: resolve::impl_map, dict_map: dict_map}; let cx = {tcx: tcx, impl_map: impl_map, method_map: method_map, dict_map: new_int_hash()}; - + fn has_iface_bounds(tps: [ty::param_bounds]) -> bool { vec::any(tps, {|bs| vec::any(*bs, {|b| @@ -2947,21 +2948,23 @@ fn resolve_dicts(tcx: ty::ctxt, impl_map: resolve::impl_map, } fn lookup_dict(tcx: ty::ctxt, isc: resolve::iscopes, sp: span, - ty: ty::t, iface_ty: ty::t) -> dict_origin { + ty: ty::t, iface_ty: ty::t) -> dict_origin { let iface_id = alt ty::struct(tcx, iface_ty) { ty::ty_iface(did, _) { did } _ { tcx.sess.abort_if_errors(); fail; } }; alt ty::struct(tcx, ty) { ty::ty_param(n, did) { + let n_bound = 0u; for bound in *tcx.ty_param_bounds.get(did.node) { alt bound { ty::bound_iface(ity) { alt ty::struct(tcx, ity) { ty::ty_iface(idid, _) { - if did == idid { ret dict_param(n); } + if iface_id == idid { ret dict_param(n, n_bound); } } } + n_bound += 1u; } _ {} } -- cgit 1.4.1-3-g733a5