@@ -1840,13 +1840,35 @@ mod unify {
1840
1840
}
1841
1841
}
1842
1842
}
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
+
1844
1866
ufind:: grow ( cx. vb . sets , ( key as uint ) + 1 u) ;
1845
1867
let root = ufind:: find ( cx. vb . sets , key as uint ) ;
1846
1868
let result_type = typ;
1847
1869
alt smallintmap:: find :: < t > ( cx. vb . types , root) {
1848
1870
some ( old_type) {
1849
- alt unify_step ( cx, old_type, typ) {
1871
+ alt unify_types ( cx, old_type, typ) {
1850
1872
ures_ok ( unified_type) { result_type = unified_type; }
1851
1873
rs { ret rs; }
1852
1874
}
@@ -2099,7 +2121,7 @@ mod unify {
2099
2121
}
2100
2122
_ {
2101
2123
// 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) {
2103
2125
ures_ok ( _) { /* fall through */ }
2104
2126
rs { ret rs; }
2105
2127
}
@@ -2113,7 +2135,7 @@ mod unify {
2113
2135
ty:: ty_var ( expected_id) {
2114
2136
// Add a binding. (`actual` can't actually be a var here.)
2115
2137
2116
- alt record_var_binding ( cx, expected_id, actual) {
2138
+ alt record_var_binding_for_expected ( cx, expected_id, actual) {
2117
2139
ures_ok ( _) { /* fall through */ }
2118
2140
rs { ret rs; }
2119
2141
}
0 commit comments