Only look for a matching method when normal field access fails
We should probalby warn when defining a method foo on {foo: int} etc.
This should reduce the amount of useless typevars that are allocated.
Issue #1227
This commit is contained in:
parent
b36ade1367
commit
f4acaf6934
10 changed files with 120 additions and 95 deletions
|
|
@ -467,11 +467,10 @@ fn print_item(s: ps, &&item: @ast::item) {
|
|||
space(s.s);
|
||||
bopen(s);
|
||||
for meth: @ast::method in _obj.methods {
|
||||
let typarams: [ast::ty_param] = [];
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
|
||||
meth.node.ident, typarams, []);
|
||||
meth.node.ident, meth.node.tps, []);
|
||||
word(s.s, " ");
|
||||
print_block(s, meth.node.meth.body);
|
||||
}
|
||||
|
|
@ -490,7 +489,7 @@ fn print_item(s: ps, &&item: @ast::item) {
|
|||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
|
||||
meth.node.ident, [], []);
|
||||
meth.node.ident, meth.node.tps, []);
|
||||
word(s.s, " ");
|
||||
print_block(s, meth.node.meth.body);
|
||||
}
|
||||
|
|
@ -964,11 +963,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||
|
||||
// Methods
|
||||
for meth: @ast::method in anon_obj.methods {
|
||||
let typarams: [ast::ty_param] = [];
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
|
||||
meth.node.ident, typarams, []);
|
||||
meth.node.ident, meth.node.tps, []);
|
||||
word(s.s, " ");
|
||||
print_block(s, meth.node.meth.body);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue