Skip to content

Commit c734c96

Browse files
committed
Merge branch 'master' of github.com:graydon/rust
2 parents 1d1010c + f6d7d75 commit c734c96

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/comp/middle/typeck.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -2287,21 +2287,13 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
22872287
alt (anon_obj.with_obj) {
22882288
case (none) { }
22892289
case (some(?e)) {
2290-
// This had better have object type. TOOD: report an
2290+
// This had better have object type. TODO: report an
22912291
// error if the user is trying to extend a non-object
22922292
// with_obj.
22932293
check_expr(fcx, e);
22942294
}
22952295
}
22962296

2297-
// Typecheck the methods.
2298-
for (@ast::method method in anon_obj.methods) {
2299-
check_method(fcx.ccx, method);
2300-
}
2301-
2302-
auto t = next_ty_var(fcx);
2303-
2304-
23052297
// FIXME: These next three functions are largely ripped off from
23062298
// similar ones in collect::. Is there a better way to do this?
23072299

@@ -2328,11 +2320,28 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
23282320
anon_obj.methods);
23292321
}
23302322

2331-
auto methods = get_anon_obj_method_types(fcx.ccx, anon_obj);
2323+
auto method_types = get_anon_obj_method_types(fcx.ccx, anon_obj);
23322324
auto ot = ty::mk_obj(fcx.ccx.tcx,
2333-
ty::sort_methods(methods));
2325+
ty::sort_methods(method_types));
23342326
write::ty_only_fixup(fcx, a.id, ot);
23352327

2328+
// Write the methods into the node type table. (This happens in
2329+
// collect::convert for regular objects.)
2330+
auto i = 0u;
2331+
while (i < vec::len[@ast::method](anon_obj.methods)) {
2332+
write::ty_only(fcx.ccx.tcx, anon_obj.methods.(i).node.ann.id,
2333+
ty::method_ty_to_fn_ty(fcx.ccx.tcx,
2334+
method_types.(i)));
2335+
i += 1u;
2336+
}
2337+
2338+
// Typecheck the methods.
2339+
for (@ast::method method in anon_obj.methods) {
2340+
check_method(fcx.ccx, method);
2341+
}
2342+
2343+
auto t = next_ty_var(fcx);
2344+
23362345
// Now remove the info from the stack.
23372346
vec::pop[obj_info](fcx.ccx.obj_infos);
23382347
}

0 commit comments

Comments
 (0)