Skip to content

Commit 4cdb37e

Browse files
committed
---
yaml --- r: 2220 b: refs/heads/master c: cf23db6 h: refs/heads/master v: v3
1 parent 5a431b2 commit 4cdb37e

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
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: c4e13cd1fa451327a756efc0c23bbbdbb9e7e1ae
2+
refs/heads/master: cf23db6be52179f2acce1577ca1045fe2b5647cb

trunk/src/comp/middle/ty.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,10 @@ fn type_contains_vars(ctxt cx, t typ) -> bool {
16291629
ret typ.has_vars;
16301630
}
16311631

1632+
fn type_contains_locals(ctxt cx, t typ) -> bool {
1633+
ret typ.has_locals;
1634+
}
1635+
16321636
fn type_contains_params(ctxt cx, t typ) -> bool {
16331637
ret typ.has_params;
16341638
}
@@ -2606,6 +2610,10 @@ mod Unify {
26062610

26072611
// Performs type binding substitution.
26082612
fn substitute(@ctxt cx, vec[t] set_types, t typ) -> t {
2613+
if (!type_contains_vars(cx.tcx, typ)) {
2614+
ret typ;
2615+
}
2616+
26092617
fn substituter(@ctxt cx, vec[t] types, t typ) -> t {
26102618
alt (struct(cx.tcx, typ)) {
26112619
case (ty_var(?id)) {
@@ -2755,8 +2763,9 @@ fn substitute_type_params(ctxt cx, vec[t] bindings, t typ) -> t {
27552763

27562764
// Converts type parameters in a type to bound type parameters.
27572765
fn bind_params_in_type(ctxt cx, t typ) -> t {
2758-
if (!type_contains_params(cx, typ)) { ret typ; }
2759-
2766+
if (!type_contains_params(cx, typ)) {
2767+
ret typ;
2768+
}
27602769
fn binder(ctxt cx, t typ) -> t {
27612770
alt (struct(cx, typ)) {
27622771
case (ty_bound_param(?index)) {

trunk/src/comp/middle/typeck.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ fn substitute_ty_params(&@crate_ctxt ccx,
9696
fail;
9797
}
9898

99+
if (!ty.type_contains_bound_params(ccx.tcx, typ)) {
100+
ret typ;
101+
}
102+
99103
auto f = bind substituter(ccx, supplied, _);
100104
ret ty.fold_ty(ccx.tcx, f, typ);
101105
}
@@ -1532,6 +1536,10 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
15321536
ret ann;
15331537
}
15341538
case (ast.ann_type(?typ, ?tps, ?ts_info)) {
1539+
auto tt = ann_to_type(ann);
1540+
if (!ty.type_contains_locals(fcx.ccx.tcx, tt)) {
1541+
ret ann;
1542+
}
15351543
auto f = bind resolver(fcx, _);
15361544
auto new_type = ty.fold_ty(fcx.ccx.tcx, f, ann_to_type(ann));
15371545
ret ast.ann_type(new_type, tps, ts_info);

0 commit comments

Comments
 (0)