Browse Source

inverted @:to field unification order (we always want to unify 'this' first)

Simon Krajewski 12 years ago
parent
commit
e3f1baafd2
2 changed files with 2 additions and 1 deletions
  1. 1 1
      type.ml
  2. 1 0
      typeload.ml

+ 1 - 1
type.ml

@@ -1168,7 +1168,7 @@ and unify_to_field ab tl a b (t,cfo) =
 		| TFun([_,_,ta],_) ->
 		| TFun([_,_,ta],_) ->
 			let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 			let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 			let map t = apply_params ab.a_types tl (apply_params cf.cf_params monos t) in
 			let map t = apply_params ab.a_types tl (apply_params cf.cf_params monos t) in
-			if loop (map t) b then try unify (map ab.a_this) (map ta); true with Unify_error _ -> false else false
+			(try unify (map ab.a_this) (map ta); loop (map t) b with Unify_error _ -> false)
 		| _ -> assert false)
 		| _ -> assert false)
 	| _ ->
 	| _ ->
 		loop (apply_params ab.a_types tl t) b
 		loop (apply_params ab.a_types tl t) b

+ 1 - 0
typeload.ml

@@ -1343,6 +1343,7 @@ let init_class ctx c p context_init herits fields =
 					end else if Meta.has Meta.To f.cff_meta then begin
 					end else if Meta.has Meta.To f.cff_meta then begin
 						let ta = monomorphs a.a_types (monomorphs params a.a_this) in
 						let ta = monomorphs a.a_types (monomorphs params a.a_this) in
 						unify ctx t (tfun [ta] m) f.cff_pos;
 						unify ctx t (tfun [ta] m) f.cff_pos;
+						if not (Meta.has Meta.Impl cf.cf_meta) then cf.cf_meta <- (Meta.Impl,[],cf.cf_pos) :: cf.cf_meta;
 						a.a_to <- (follow m, Some cf) :: a.a_to
 						a.a_to <- (follow m, Some cf) :: a.a_to
 					end
 					end
 				| _ ->
 				| _ ->