|
4 | 4 | use /*mod*/ syntax::ast;
|
5 | 5 | use /*mod*/ syntax::visit;
|
6 | 6 | use syntax::ast_map;
|
7 |
| -use syntax::ast::{def_variant, expr_field, expr_struct, expr_unary, ident, |
8 |
| - item_class}; |
9 |
| -use syntax::ast::{item_impl, item_trait, item_enum, local_crate, node_id, |
10 |
| - pat_struct}; |
11 |
| -use syntax::ast::{private, provided, required}; |
| 7 | +use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct}; |
| 8 | +use syntax::ast::{expr_unary, ident, item_class, item_enum, item_impl}; |
| 9 | +use syntax::ast::{item_trait, local_crate, node_id, pat_struct, private}; |
| 10 | +use syntax::ast::{provided, required}; |
12 | 11 | use syntax::ast_map::{node_item, node_method};
|
13 |
| -use syntax::ast_util::{has_legacy_export_attr, is_local, |
14 |
| - visibility_to_privacy, Private, Public}; |
| 12 | +use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local}; |
| 13 | +use syntax::ast_util::{visibility_to_privacy}; |
15 | 14 | use ty::{ty_class, ty_enum};
|
16 | 15 | use typeck::{method_map, method_origin, method_param, method_self};
|
17 | 16 | use typeck::{method_static, method_trait};
|
@@ -213,6 +212,27 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
213 | 212 | _ => {}
|
214 | 213 | }
|
215 | 214 | }
|
| 215 | + expr_method_call(base, _, _, _, _) => { |
| 216 | + match ty::get(ty::expr_ty(tcx, base)).sty { |
| 217 | + ty_class(id, _) |
| 218 | + if id.crate != local_crate || |
| 219 | + !privileged_items.contains(&(id.node)) => { |
| 220 | + match method_map.find(expr.id) { |
| 221 | + None => { |
| 222 | + tcx.sess.span_bug(expr.span, |
| 223 | + ~"method call not in \ |
| 224 | + method map"); |
| 225 | + } |
| 226 | + Some(entry) => { |
| 227 | + debug!("(privacy checking) checking \ |
| 228 | + impl method"); |
| 229 | + check_method(expr.span, &entry.origin); |
| 230 | + } |
| 231 | + } |
| 232 | + } |
| 233 | + _ => {} |
| 234 | + } |
| 235 | + } |
216 | 236 | expr_struct(_, fields, _) => {
|
217 | 237 | match ty::get(ty::expr_ty(tcx, expr)).sty {
|
218 | 238 | ty_class(id, _) => {
|
|
0 commit comments