Skip to content

Commit f7444a6

Browse files
committed
---
yaml --- r: 5833 b: refs/heads/master c: f7a825c h: refs/heads/master i: 5831: e5b2cb4 v: v3
1 parent cddfc79 commit f7444a6

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
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: 1a64153b244183f215241e8c8c2c115076239ba3
2+
refs/heads/master: f7a825c6148ab634d2804508118dec939c41136d

trunk/src/comp/middle/ty.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,13 +1840,35 @@ mod unify {
18401840
}
18411841
}
18421842
}
1843-
fn record_var_binding(cx: @ctxt, key: int, typ: t) -> result {
1843+
1844+
fn record_var_binding_for_expected(
1845+
cx: @ctxt, key: int, typ: t) -> result {
1846+
record_var_binding(
1847+
cx, key, typ,
1848+
fn (cx: @ctxt, old_type: t, new_type: t) -> result {
1849+
unify_step(cx, old_type, new_type)
1850+
})
1851+
}
1852+
1853+
fn record_var_binding_for_actual(
1854+
cx: @ctxt, key: int, typ: t) -> result {
1855+
record_var_binding(
1856+
cx, key, typ,
1857+
fn (cx: @ctxt, old_type: t, new_type: t) -> result {
1858+
unify_step(cx, new_type, old_type)
1859+
})
1860+
}
1861+
1862+
fn record_var_binding(
1863+
cx: @ctxt, key: int, typ: t,
1864+
unify_types: fn(@ctxt, t, t) -> result) -> result {
1865+
18441866
ufind::grow(cx.vb.sets, (key as uint) + 1u);
18451867
let root = ufind::find(cx.vb.sets, key as uint);
18461868
let result_type = typ;
18471869
alt smallintmap::find::<t>(cx.vb.types, root) {
18481870
some(old_type) {
1849-
alt unify_step(cx, old_type, typ) {
1871+
alt unify_types(cx, old_type, typ) {
18501872
ures_ok(unified_type) { result_type = unified_type; }
18511873
rs { ret rs; }
18521874
}
@@ -2099,7 +2121,7 @@ mod unify {
20992121
}
21002122
_ {
21012123
// Just bind the type variable to the expected type.
2102-
alt record_var_binding(cx, actual_id, expected) {
2124+
alt record_var_binding_for_actual(cx, actual_id, expected) {
21032125
ures_ok(_) {/* fall through */ }
21042126
rs { ret rs; }
21052127
}
@@ -2113,7 +2135,7 @@ mod unify {
21132135
ty::ty_var(expected_id) {
21142136
// Add a binding. (`actual` can't actually be a var here.)
21152137

2116-
alt record_var_binding(cx, expected_id, actual) {
2138+
alt record_var_binding_for_expected(cx, expected_id, actual) {
21172139
ures_ok(_) {/* fall through */ }
21182140
rs { ret rs; }
21192141
}

0 commit comments

Comments
 (0)