Skip to content

Commit

Permalink
[js] consider statics of @:native("") classes when renaming local vars (
Browse files Browse the repository at this point in the history
closes #6448)
  • Loading branch information
nadako committed Jul 18, 2017
1 parent 6d89668 commit 9e712ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/optimization/filters.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,20 @@ let collect_reserved_local_names com =
match com.platform with
| Js ->
let h = ref StringMap.empty in
let add name = h := StringMap.add name true !h in
List.iter (fun mt ->
let tinfos = t_infos mt in
let native_name = try fst (get_native_name tinfos.mt_meta) with Not_found -> Path.flat_path tinfos.mt_path in
h := StringMap.add native_name true !h
if native_name = "" then
match mt with
| TClassDecl c ->
List.iter (fun cf ->
let native_name = try fst (get_native_name cf.cf_meta) with Not_found -> cf.cf_name in
add native_name
) c.cl_ordered_statics;
| _ -> ()
else
add native_name
) com.types;
!h
| _ -> StringMap.empty
Expand Down
17 changes: 15 additions & 2 deletions tests/unit/src/unit/issues/Issue6448.hx
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package unit.issues;

@:native("some")
@:native("some6448")
private class C {
public var v = true;
public function new() {}
}

@:native("")
private extern class Lib {
@:native("___hx_returnTrue")
static function returnTrue():Bool;

static function __init__():Void {
untyped __js__("function ___hx_returnTrue() { return true; }");
}
}

class Issue6448 extends unit.Test {
#if js
@:analyzer(no_local_dce)
function test() {
var some = null;
var some6448 = null;
t(new C().v);

function ___hx_returnTrue() return false;
t(Lib.returnTrue());
}
#end
}

0 comments on commit 9e712ce

Please sign in to comment.