|
@@ -1535,16 +1535,18 @@ and unify_to_field ab tl b ?(allow_transitive_cast=true) (t,cfo) =
|
|
r
|
|
r
|
|
end
|
|
end
|
|
|
|
|
|
-and unify_with_variance t1 t2 =
|
|
|
|
|
|
+and unify_with_variance f t1 t2 =
|
|
let allows_variance_to t (tf,cfo) = match cfo with
|
|
let allows_variance_to t (tf,cfo) = match cfo with
|
|
| None -> type_iseq tf t
|
|
| None -> type_iseq tf t
|
|
| Some _ -> false
|
|
| Some _ -> false
|
|
in
|
|
in
|
|
match follow t1,follow t2 with
|
|
match follow t1,follow t2 with
|
|
| TInst(c1,tl1),TInst(c2,tl2) when c1 == c2 ->
|
|
| TInst(c1,tl1),TInst(c2,tl2) when c1 == c2 ->
|
|
- List.iter2 unify_with_variance tl1 tl2
|
|
|
|
|
|
+ List.iter2 f tl1 tl2
|
|
| TEnum(en1,tl1),TEnum(en2,tl2) when en1 == en2 ->
|
|
| TEnum(en1,tl1),TEnum(en2,tl2) when en1 == en2 ->
|
|
- List.iter2 unify_with_variance tl1 tl2
|
|
|
|
|
|
+ List.iter2 f tl1 tl2
|
|
|
|
+ | TAbstract(a1,tl1),TAbstract(a2,tl2) when a1 == a2 && Meta.has Meta.CoreType a1.a_meta ->
|
|
|
|
+ List.iter2 f tl1 tl2
|
|
| TAbstract(a1,pl1),TAbstract(a2,pl2) ->
|
|
| TAbstract(a1,pl1),TAbstract(a2,pl2) ->
|
|
let ta1 = apply_params a1.a_types pl1 a1.a_this in
|
|
let ta1 = apply_params a1.a_types pl1 a1.a_this in
|
|
let ta2 = apply_params a2.a_types pl2 a2.a_this in
|
|
let ta2 = apply_params a2.a_types pl2 a2.a_this in
|
|
@@ -1574,7 +1576,7 @@ and with_variance f t1 t2 =
|
|
try
|
|
try
|
|
f t1 t2
|
|
f t1 t2
|
|
with Unify_error l -> try
|
|
with Unify_error l -> try
|
|
- unify_with_variance t1 t2
|
|
|
|
|
|
+ unify_with_variance (with_variance f) t1 t2
|
|
with Unify_error _ ->
|
|
with Unify_error _ ->
|
|
raise (Unify_error l)
|
|
raise (Unify_error l)
|
|
|
|
|