Skip to content

Commit

Permalink
Resolve bounds in iface types
Browse files Browse the repository at this point in the history
Closes #2311
  • Loading branch information
catamorphism committed May 29, 2012
1 parent f90228b commit 8d7765b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/librustsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
v.visit_ty_params(tps, e, v);
for methods.each {|m|
for m.decl.inputs.each {|a| v.visit_ty(a.ty, e, v); }
v.visit_ty_params(m.tps, e, v);
v.visit_ty(m.decl.output, e, v);
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/rustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
let sc = @cons(scope_item(i), sc);
alt i.node {
ast::item_impl(tps, _, ifce, sty, methods) {
visit::visit_ty_params(tps, sc, v);
v.visit_ty_params(tps, sc, v);
option::iter(ifce) {|p| visit::visit_path(p.path, sc, v)};
v.visit_ty(sty, sc, v);
for methods.each {|m|
Expand All @@ -560,15 +560,17 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
}
}
ast::item_iface(tps, _, methods) {
visit::visit_ty_params(tps, sc, v);
v.visit_ty_params(tps, sc, v);
let isc = @cons(scope_method(i.id, tps), sc);
for methods.each {|m|
v.visit_ty_params(m.tps, isc, v);
let msc = @cons(scope_method(i.id, tps + m.tps), sc);
for m.decl.inputs.each {|a| v.visit_ty(a.ty, msc, v); }
v.visit_ty(m.decl.output, msc, v);
}
}
ast::item_class(tps, ifaces, members, ctor, m_dtor, _) {
visit::visit_ty_params(tps, sc, v);
v.visit_ty_params(tps, sc, v);
// Can maybe skip this now that we require self on class fields
let class_scope = @cons(scope_item(i), sc);
/* visit the constructor... */
Expand Down
6 changes: 6 additions & 0 deletions src/test/run-pass/issue-2311.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
iface clam<A> { }
iface foo<A> {
fn bar<B,C:clam<A>>(c: C) -> B;
}

fn main() { }

0 comments on commit 8d7765b

Please sign in to comment.