Make typeck::collect aware of provided methods in traits.
This commit is contained in:
parent
2fe299d1a5
commit
65e0e30e59
@ -329,6 +329,18 @@ fn trait_method_to_ty_method(method: trait_method) -> ty_method {
|
||||
}
|
||||
}
|
||||
|
||||
fn split_trait_methods(trait_methods: ~[trait_method])
|
||||
-> (~[ty_method], ~[@method]) {
|
||||
let mut reqd = ~[], provd = ~[];
|
||||
for trait_methods.each |trt_method| {
|
||||
alt trt_method {
|
||||
required(tm) { vec::push(reqd, tm); }
|
||||
provided(m) { vec::push(provd, m); }
|
||||
}
|
||||
};
|
||||
(reqd, provd)
|
||||
}
|
||||
|
||||
pure fn class_member_visibility(ci: @class_member) -> visibility {
|
||||
alt ci.node {
|
||||
instance_var(_, _, _, _, vis) { vis }
|
||||
|
@ -43,7 +43,8 @@ import syntax::{ast, ast_util, ast_map};
|
||||
import ast::spanned;
|
||||
import ast::{required, provided};
|
||||
import syntax::ast_map::node_id_to_str;
|
||||
import syntax::ast_util::{local_def, respan, split_class_items};
|
||||
import syntax::ast_util::{local_def, respan, split_class_items,
|
||||
split_trait_methods};
|
||||
import syntax::visit;
|
||||
import metadata::csearch;
|
||||
import driver::session::session;
|
||||
|
@ -339,12 +339,22 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
||||
check_methods_against_trait(ccx, tps, rp, selfty, t, cms);
|
||||
}
|
||||
}
|
||||
ast::item_trait(*) {
|
||||
ast::item_trait(tps, trait_methods) {
|
||||
let tpt = ty_of_item(ccx, it);
|
||||
debug!{"item_trait(it.id=%d, tpt.ty=%s)",
|
||||
it.id, ty_to_str(tcx, tpt.ty)};
|
||||
write_ty_to_tcx(tcx, it.id, tpt.ty);
|
||||
ensure_trait_methods(ccx, it.id);
|
||||
|
||||
let (_, provided_methods) = split_trait_methods(trait_methods);
|
||||
let selfty = ty::mk_self(tcx);
|
||||
let {bounds, _} = mk_substs(ccx, tps, rp);
|
||||
let _cms = convert_methods(ccx, provided_methods, rp, bounds, selfty);
|
||||
// FIXME (#2616): something like this, when we start having
|
||||
// trait inheritance?
|
||||
// for trt.each |t| {
|
||||
// check_methods_against_trait(ccx, tps, rp, selfty, t, cms);
|
||||
// }
|
||||
}
|
||||
ast::item_class(tps, traits, members, m_ctor, m_dtor) {
|
||||
// Write the class type
|
||||
|
Loading…
x
Reference in New Issue
Block a user