Skip to content

Commit

Permalink
use TMeta instead of field hack to communicate when an abstract assig…
Browse files Browse the repository at this point in the history
…nment overloads requires an assignment (closes HaxeFoundation#2405)
  • Loading branch information
Simn committed Dec 1, 2013
1 parent 441d6a3 commit 1c25e98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ module Meta = struct
| RealPath
| Remove
| Require
| RequiresAssign
| ReplaceReflection
| Rtti
| Runtime
Expand Down
1 change: 1 addition & 0 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ module MetaInfo = struct
| RealPath -> ":realPath",("Internally used on @:native types to retain original path information",[Internal])
| Remove -> ":remove",("Causes an interface to be removed from all implementing classes before generation",[UsedOn TClass])
| Require -> ":require",("Allows access to a field only if the specified compiler flag is set",[HasParam "Compiler flag to check";UsedOn TClassField])
| RequiresAssign -> ":requiresAssign",("Used internally to mark certain abstract operator overloads",[Internal])
| ReplaceReflection -> ":replaceReflection",("Used internally to specify a function that should replace its internal __hx_functionName counterpart",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum]; Internal])
| Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass])
| Runtime -> ":runtime",("?",[])
Expand Down
5 changes: 2 additions & 3 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
unify ctx eop.etype e.etype p;
check_assign ctx e;
mk (TBinop (OpAssignOp op,e,e2)) e.etype p;
| TField(e2,FDynamic ":needsAssign") ->
| TMeta((Meta.RequiresAssign,_,_),e2) ->
unify ctx e2.etype e.etype p;
check_assign ctx e;
mk (TBinop (OpAssign,e,e2)) e.etype p;
Expand Down Expand Up @@ -1825,8 +1825,7 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
let et = type_module_type ctx (TClassDecl c) None p in
let ef = mk (TField (et,FStatic (c,f))) t p in
let ec = make_call ctx ef [e1;e2] r p in
(* obviously a hack to report back that we need an assignment *)
if is_assign_op && not assign then mk (TField(ec,FDynamic ":needsAssign")) t_dynamic p else ec
if is_assign_op && not assign then mk (TMeta((Meta.RequiresAssign,[],ec.epos),ec)) ec.etype ec.epos else ec
in
let cast_rec e1t e2t r is_core_type =
if is_core_type then
Expand Down

0 comments on commit 1c25e98

Please sign in to comment.