Skip to content

Commit e02f673

Browse files
committed
---
yaml --- r: 2523 b: refs/heads/master c: fac1342 h: refs/heads/master i: 2521: cb61f10 2519: d102e81 v: v3
1 parent c84f34b commit e02f673

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 843e9435ab5c83d4f255ee2ecd2fe5752ec2f715
2+
refs/heads/master: fac13425138bdadae8ab738efa538641af33c12e

trunk/src/comp/middle/ty.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,50 +1721,6 @@ fn expr_has_ty_params(&node_type_table ntt, &@ast::expr expr) -> bool {
17211721
ret ann_has_type_params(ntt, expr_ann(expr));
17221722
}
17231723

1724-
// FIXME: At the moment this works only for call, bind, and path expressions.
1725-
fn replace_expr_type(&node_type_table ntt,
1726-
&@ast::expr expr,
1727-
&tup(vec[t], t) new_tyt) -> @ast::expr {
1728-
auto new_tps;
1729-
if (expr_has_ty_params(ntt, expr)) {
1730-
new_tps = some[vec[t]](new_tyt._0);
1731-
} else {
1732-
new_tps = none[vec[t]];
1733-
}
1734-
1735-
fn mkann_fn(t tyt, option::t[vec[t]] tps, &ast::ann old_ann) -> ast::ann {
1736-
ret ast::ann_type(ast::ann_tag(old_ann), tyt, tps, none[@ts_ann]);
1737-
}
1738-
auto mkann = bind mkann_fn(new_tyt._1, new_tps, _);
1739-
1740-
alt (expr.node) {
1741-
case (ast::expr_call(?callee, ?args, ?a)) {
1742-
ret @fold::respan(expr.span,
1743-
ast::expr_call(callee, args, mkann(a)));
1744-
}
1745-
case (ast::expr_self_method(?ident, ?a)) {
1746-
ret @fold::respan(expr.span,
1747-
ast::expr_self_method(ident, mkann(a)));
1748-
}
1749-
case (ast::expr_bind(?callee, ?args, ?a)) {
1750-
ret @fold::respan(expr.span,
1751-
ast::expr_bind(callee, args, mkann(a)));
1752-
}
1753-
case (ast::expr_field(?e, ?i, ?a)) {
1754-
ret @fold::respan(expr.span,
1755-
ast::expr_field(e, i, mkann(a)));
1756-
}
1757-
case (ast::expr_path(?p, ?a)) {
1758-
ret @fold::respan(expr.span,
1759-
ast::expr_path(p, mkann(a)));
1760-
}
1761-
case (_) {
1762-
log_err "unhandled expr type in replace_expr_type(): " +
1763-
util::common::expr_to_str(expr);
1764-
fail;
1765-
}
1766-
}
1767-
}
17681724

17691725
// Expression utilities
17701726

trunk/src/comp/middle/typeck.rs

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,57 @@ fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast::block block)
17091709
ret fold::fold_block[option::t[@fn_ctxt]](some(fcx), fld, block);
17101710
}
17111711

1712+
1713+
// AST fragment utilities
1714+
1715+
// FIXME: At the moment this works only for call, bind, and path expressions.
1716+
fn replace_expr_type(&node_type_table ntt,
1717+
&@ast::expr expr,
1718+
&tup(vec[ty::t], ty::t) new_tyt) -> @ast::expr {
1719+
auto new_tps;
1720+
if (ty::expr_has_ty_params(ntt, expr)) {
1721+
new_tps = some[vec[ty::t]](new_tyt._0);
1722+
} else {
1723+
new_tps = none[vec[ty::t]];
1724+
}
1725+
1726+
fn mkann_fn(ty::t tyt, option::t[vec[ty::t]] tps, &ast::ann old_ann)
1727+
-> ast::ann {
1728+
ret ast::ann_type(ast::ann_tag(old_ann), tyt, tps, none[@ts_ann]);
1729+
}
1730+
1731+
auto mkann = bind mkann_fn(new_tyt._1, new_tps, _);
1732+
1733+
alt (expr.node) {
1734+
case (ast::expr_call(?callee, ?args, ?a)) {
1735+
ret @fold::respan(expr.span,
1736+
ast::expr_call(callee, args, mkann(a)));
1737+
}
1738+
case (ast::expr_self_method(?ident, ?a)) {
1739+
ret @fold::respan(expr.span,
1740+
ast::expr_self_method(ident, mkann(a)));
1741+
}
1742+
case (ast::expr_bind(?callee, ?args, ?a)) {
1743+
ret @fold::respan(expr.span,
1744+
ast::expr_bind(callee, args, mkann(a)));
1745+
}
1746+
case (ast::expr_field(?e, ?i, ?a)) {
1747+
ret @fold::respan(expr.span,
1748+
ast::expr_field(e, i, mkann(a)));
1749+
}
1750+
case (ast::expr_path(?p, ?a)) {
1751+
ret @fold::respan(expr.span,
1752+
ast::expr_path(p, mkann(a)));
1753+
}
1754+
case (_) {
1755+
log_err "unhandled expr type in replace_expr_type(): " +
1756+
util::common::expr_to_str(expr);
1757+
fail;
1758+
}
1759+
}
1760+
}
1761+
1762+
17121763
// AST fragment checking
17131764

17141765
fn check_lit(@crate_ctxt ccx, &@ast::lit lit) -> ty::t {
@@ -1935,7 +1986,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
19351986
fcx.ccx.node_types, f_0);
19361987
auto tpt_1 = Demand::full(fcx, f.span, tpt_0._1, t_0, tpt_0._0,
19371988
NO_AUTODEREF);
1938-
auto f_1 = ty::replace_expr_type(fcx.ccx.node_types, f_0, tpt_1);
1989+
auto f_1 = replace_expr_type(fcx.ccx.node_types, f_0, tpt_1);
19391990

19401991
ret tup(f_1, args_0);
19411992
}

0 commit comments

Comments
 (0)