Parcourir la source

remap `this` after retrieving it from the this_stack because we might be in a closure

Simon Krajewski il y a 11 ans
Parent
commit
b518a827ef
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      typer.ml

+ 6 - 1
typer.ml

@@ -3291,7 +3291,12 @@ and type_expr ctx (e,p) (with_type:with_type) =
 					| TAbstract({a_impl = Some c},_) when PMap.mem "toString" c.cl_statics -> call_to_string ctx c e
 					| TAbstract({a_impl = Some c},_) when PMap.mem "toString" c.cl_statics -> call_to_string ctx c e
 					| _ -> e)
 					| _ -> e)
 			| (Meta.This,_,_) ->
 			| (Meta.This,_,_) ->
-				List.hd ctx.this_stack
+				let e = List.hd ctx.this_stack in
+				let rec loop e = match e.eexpr with
+					| TConst TThis -> get_this ctx e.epos
+					| _ -> Type.map_expr loop e
+				in
+				loop e
 			| _ -> e()
 			| _ -> e()
 		in
 		in
 		ctx.meta <- old;
 		ctx.meta <- old;