Stop resolving static methods at the module level. Closes #4179

This commit is contained in:
Brian Anderson 2012-12-18 18:05:16 -08:00
parent 8e28f23c60
commit 97ddf3c7bd
25 changed files with 74 additions and 82 deletions

View file

@ -36,7 +36,7 @@ impl bool: read {
}
fn read<T: read Copy>(s: ~str) -> T {
match readMaybe(s) {
match read::readMaybe(s) {
Some(x) => x,
_ => fail ~"read failed!"
}

View file

@ -22,7 +22,7 @@ use std::ebml;
use EBReader = std::ebml::reader;
use EBWriter = std::ebml::writer;
use io::Writer;
use std::serialize::{Encodable, Decodable, decode};
use std::serialize::traits::{Encodable, Decodable};
use std::prettyprint;
use std::time;
@ -47,7 +47,7 @@ fn test_ebml<A:
a1.encode(ebml_w)
};
let d = EBReader::Doc(@move bytes);
let a2: A = decode(&EBReader::Decoder(d));
let a2: A = Decodable::decode(&EBReader::Decoder(d));
assert *a1 == a2;
}

View file

@ -16,5 +16,5 @@ extern mod mycore(name ="static_fn_inline_xc_aux");
use mycore::num;
fn main() {
let _1:float = num::from_int2(1i);
let _1:float = num::Num2::from_int2(1i);
}

View file

@ -6,5 +6,5 @@ extern mod mycore(name ="static_fn_trait_xc_aux");
use mycore::num;
fn main() {
let _1:float = num::from_int2(1i);
let _1:float = num::Num2::from_int2(1i);
}

View file

@ -30,6 +30,6 @@ impl FromThinAir: Deserializer {
fn main() {
let d = FromThinAir { dummy: () };
let i: int = deserialize(&d);
let i: int = Deserializable::deserialize(&d);
assert i == 22;
}

View file

@ -18,7 +18,7 @@ trait bool_like {
}
fn andand<T: bool_like Copy>(x1: T, x2: T) -> T {
select(x1, x2, x1)
bool_like::select(x1, x2, x1)
}
impl bool: bool_like {
@ -57,7 +57,7 @@ impl<A> ~[A]: buildable<A> {
#[inline(always)]
pure fn build<A, B: buildable<A>>(builder: fn(push: pure fn(+v: A))) -> B {
build_sized(4, builder)
buildable::build_sized(4, builder)
}
/// Apply a function to each element of an iterable and return the results
@ -71,7 +71,7 @@ fn map<T, IT: BaseIter<T>, U, BU: buildable<U>>
}
fn seq_range<BT: buildable<int>>(lo: uint, hi: uint) -> BT {
do build_sized(hi-lo) |push| {
do buildable::build_sized(hi-lo) |push| {
for uint::range(lo, hi) |i| {
push(i as int);
}
@ -87,7 +87,7 @@ fn main() {
let v: ~[int] = map(&[1,2,3], |x| 1+x);
assert v == ~[2, 3, 4];
assert select(true, 9, 14) == 9;
assert bool_like::select(true, 9, 14) == 9;
assert !andand(true, false);
assert andand(7, 12) == 12;
assert andand(0, 12) == 0;

View file

@ -14,7 +14,7 @@
extern mod static_methods_crate;
use static_methods_crate::read;
use readMaybeRenamed = static_methods_crate::readMaybe;
use readMaybeRenamed = static_methods_crate::read::readMaybe;
fn main() {
let result: int = read(~"5");

View file

@ -11,7 +11,7 @@
// except according to those terms.
use cmp::{Eq, Ord};
use num::from_int;
use num::Num::from_int;
extern mod std;
use std::cmp::FuzzyEq;

View file

@ -12,7 +12,7 @@
// Extending Num and using inherited static methods
use num::from_int;
use Num::from_int;
trait Num {
static fn from_int(i: int) -> self;

View file

@ -11,7 +11,7 @@
// Using the real Num from core
use cmp::Ord;
use num::from_int;
use num::Num::from_int;
pub trait NumExt: Num Ord { }

View file

@ -13,7 +13,7 @@
// A more complex example of numeric extensions
use cmp::{Eq, Ord};
use num::from_int;
use num::Num::from_int;
extern mod std;
use std::cmp::FuzzyEq;

View file

@ -9,7 +9,7 @@
// except according to those terms.
use cmp::{Eq, Ord};
use num::from_int;
use num::Num::from_int;
pub trait NumExt: Eq Ord Num {}

View file

@ -9,7 +9,7 @@
// except according to those terms.
use cmp::{Eq, Ord};
use num::from_int;
use num::Num::from_int;
pub trait NumExt: Eq Num {}

View file

@ -26,7 +26,7 @@ impl S: MyNum {
impl S: NumExt { }
fn greater_than_one<T:NumExt>() -> T { from_int(1) }
fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
fn main() {
let v: S = greater_than_one();

View file

@ -30,7 +30,7 @@ impl S: MyNum {
impl S: NumExt { }
fn greater_than_one<T:NumExt>() -> T { from_int(1) }
fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
fn main() {
let v: S = greater_than_one();

View file

@ -37,6 +37,6 @@ mod base {
}
fn main() {
let f: base::Foo = base::new::<base::Foo, base::Foo>();
let b: base::Bar = base::new::<base::Bar, base::Bar>();
let f: base::Foo = base::HasNew::new::<base::Foo, base::Foo>();
let b: base::Bar = base::HasNew::new::<base::Bar, base::Bar>();
}

View file

@ -37,9 +37,9 @@ enum ColorTree {
impl ColorTree : Equal {
static fn isEq(a: ColorTree, b: ColorTree) -> bool {
match (a, b) {
(leaf(x), leaf(y)) => { isEq(x, y) }
(leaf(x), leaf(y)) => { Equal::isEq(x, y) }
(branch(l1, r1), branch(l2, r2)) => {
isEq(*l1, *l2) && isEq(*r1, *r2)
Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2)
}
_ => { false }
}
@ -47,18 +47,18 @@ impl ColorTree : Equal {
}
fn main() {
assert isEq(cyan, cyan);
assert isEq(magenta, magenta);
assert !isEq(cyan, yellow);
assert !isEq(magenta, cyan);
assert Equal::isEq(cyan, cyan);
assert Equal::isEq(magenta, magenta);
assert !Equal::isEq(cyan, yellow);
assert !Equal::isEq(magenta, cyan);
assert isEq(leaf(cyan), leaf(cyan));
assert !isEq(leaf(cyan), leaf(yellow));
assert Equal::isEq(leaf(cyan), leaf(cyan));
assert !Equal::isEq(leaf(cyan), leaf(yellow));
assert isEq(branch(@leaf(magenta), @leaf(cyan)),
assert Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(cyan)));
assert !isEq(branch(@leaf(magenta), @leaf(cyan)),
assert !Equal::isEq(branch(@leaf(magenta), @leaf(cyan)),
branch(@leaf(magenta), @leaf(magenta)));
log(error, "Assertions all succeeded!");