diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-03-26 10:45:04 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-03-26 10:46:37 -0700 |
| commit | 11610f9ca1a9da187c1b6f0d40ae2e369afd4fee (patch) | |
| tree | c55c23bac3d33720382394ee20e348bf31fbc307 /src | |
| parent | 21111660ca7dbd95f9b0ee8c651062a607fe6345 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/typeck.rs | 4 | ||||
| -rw-r--r-- | src/test/auxiliary/cci_class_5.rs | 14 | ||||
| -rw-r--r-- | src/test/compile-fail/private-class-field-cross-crate.rs | 10 | ||||
| -rw-r--r-- | src/test/compile-fail/private-method-cross-crate.rs | 10 | ||||
| -rw-r--r-- | src/test/compile-fail/private-method.rs | 2 |
5 files changed, 37 insertions, 3 deletions
diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 20b705f0738..165ca33a15f 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -934,8 +934,8 @@ mod collect { } ast_map::node_item(@{node: ast::item_class(_,its,_), _}, _) { let (_,ms) = split_class_items(its); - // Handling all methods here - let ps = ast_util::ignore_privacy(ms); + // Only public methods need to be stored + let ps = ast_util::public_methods(ms); store_methods::<@ast::method>(tcx, id, ps, {|m| ty_of_method(tcx, m_collect, m)}); } diff --git a/src/test/auxiliary/cci_class_5.rs b/src/test/auxiliary/cci_class_5.rs new file mode 100644 index 00000000000..a2995bf2986 --- /dev/null +++ b/src/test/auxiliary/cci_class_5.rs @@ -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; } +} + +} \ No newline at end of file diff --git a/src/test/compile-fail/private-class-field-cross-crate.rs b/src/test/compile-fail/private-class-field-cross-crate.rs new file mode 100644 index 00000000000..b96adc19cbb --- /dev/null +++ b/src/test/compile-fail/private-class-field-cross-crate.rs @@ -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); +} diff --git a/src/test/compile-fail/private-method-cross-crate.rs b/src/test/compile-fail/private-method-cross-crate.rs new file mode 100644 index 00000000000..279c61db26c --- /dev/null +++ b/src/test/compile-fail/private-method-cross-crate.rs @@ -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(); +} diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs index 8b257c11cd9..7dc1f44d71b 100644 --- a/src/test/compile-fail/private-method.rs +++ b/src/test/compile-fail/private-method.rs @@ -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 { priv { let mutable meows : uint; |
