Fix vtable calculations when translating static methods. Closes #4165
This commit is contained in:
parent
0494b078a9
commit
6047dd35bb
@ -515,15 +515,7 @@ fn combine_impl_and_methods_origins(bcx: block,
|
||||
let m_boundss = vec::view(*r_m_bounds, n_r_m_tps - n_m_tps, n_r_m_tps);
|
||||
|
||||
// Flatten out to find the number of vtables the method expects.
|
||||
let m_vtables = m_boundss.foldl(0, |sum, m_bounds| {
|
||||
m_bounds.foldl(*sum, |sum, m_bound| {
|
||||
(*sum) + match (*m_bound) {
|
||||
ty::bound_copy | ty::bound_owned |
|
||||
ty::bound_send | ty::bound_const => 0,
|
||||
ty::bound_trait(_) => 1
|
||||
}
|
||||
})
|
||||
});
|
||||
let m_vtables = ty::count_traits_and_supertraits(tcx, m_boundss);
|
||||
|
||||
// Find the vtables we computed at type check time and monomorphize them
|
||||
let r_m_origins = match node_vtables(bcx, callee_id) {
|
||||
|
19
src/test/run-pass/static-methods-in-traits2.rs
Normal file
19
src/test/run-pass/static-methods-in-traits2.rs
Normal file
@ -0,0 +1,19 @@
|
||||
pub trait Number: NumConv {
|
||||
static pure fn from<T:Number>(n: T) -> self;
|
||||
}
|
||||
|
||||
pub impl float: Number {
|
||||
static pure fn from<T:Number>(n: T) -> float { n.to_float() }
|
||||
}
|
||||
|
||||
pub trait NumConv {
|
||||
pure fn to_float(&self) -> float;
|
||||
}
|
||||
|
||||
pub impl float: NumConv {
|
||||
pure fn to_float(&self) -> float { *self }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: float = Number::from(0.0f);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user