In typeck, don't call ty::store_iface_methods on private methods

This was resulting in a different error message depending on whether
the private method you were trying to call was in the same crate
or a different one.
This commit is contained in:
Tim Chevalier
2012-03-26 10:45:04 -07:00
parent 21111660ca
commit 11610f9ca1
5 changed files with 37 additions and 3 deletions

View File

@@ -934,8 +934,8 @@ mod collect {
} }
ast_map::node_item(@{node: ast::item_class(_,its,_), _}, _) { ast_map::node_item(@{node: ast::item_class(_,its,_), _}, _) {
let (_,ms) = split_class_items(its); let (_,ms) = split_class_items(its);
// Handling all methods here // Only public methods need to be stored
let ps = ast_util::ignore_privacy(ms); let ps = ast_util::public_methods(ms);
store_methods::<@ast::method>(tcx, id, ps, {|m| store_methods::<@ast::method>(tcx, id, ps, {|m|
ty_of_method(tcx, m_collect, m)}); ty_of_method(tcx, m_collect, m)});
} }

View File

@@ -0,0 +1,14 @@
mod kitties {
class cat {
priv {
let mutable meows : uint;
fn nap() { uint::range(1u, 10000u) {|_i|}}
}
let how_hungry : int;
new(in_x : uint, in_y : int) { meows = in_x; how_hungry = in_y; }
}
}

View File

@@ -0,0 +1,10 @@
// error-pattern:no public field or method with that name
// xfail-fast
// aux-build:cci_class.rs
use cci_class;
import cci_class::kitties::*;
fn main() {
let nyan : cat = cat(52u, 99);
assert (nyan.meows == 52u);
}

View File

@@ -0,0 +1,10 @@
// error-pattern:attempted access of field nap on type
// xfail-fast
// aux-build:cci_class_5.rs
use cci_class_5;
import cci_class_5::kitties::*;
fn main() {
let nyan : cat = cat(52u, 99);
nyan.nap();
}

View File

@@ -1,4 +1,4 @@
// error-pattern:Class doesn't have a public method named nap // error-pattern:attempted access of field nap on type
class cat { class cat {
priv { priv {
let mutable meows : uint; let mutable meows : uint;