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:
@@ -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)});
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/test/auxiliary/cci_class_5.rs
Normal file
14
src/test/auxiliary/cci_class_5.rs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
src/test/compile-fail/private-class-field-cross-crate.rs
Normal file
10
src/test/compile-fail/private-class-field-cross-crate.rs
Normal 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);
|
||||||
|
}
|
||||||
10
src/test/compile-fail/private-method-cross-crate.rs
Normal file
10
src/test/compile-fail/private-method-cross-crate.rs
Normal 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();
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user