rustc: Resolve bounds of trait type parameters

This commit is contained in:
Brian Anderson 2012-07-12 18:04:40 -07:00
parent 18da7fef88
commit dac4916cec
2 changed files with 27 additions and 0 deletions

View File

@ -2920,6 +2920,8 @@ class Resolver {
NormalRibKind))
|| {
self.resolve_type_parameters(type_parameters, visitor);
for methods.each |method| {
// Create a new rib for the method-specific type
// parameters.

View File

@ -0,0 +1,25 @@
trait connection {
fn read() -> int;
}
trait connection_factory<C: connection> {
fn create() -> C;
}
type my_connection = ();
type my_connection_factory = ();
impl of connection for () {
fn read() -> int { 43 }
}
impl of connection_factory<my_connection> for my_connection_factory {
fn create() -> my_connection { () }
}
fn main() {
let factory = ();
let connection = factory.create();
let result = connection.read();
assert result == 43;
}