Skip to content

Commit

Permalink
[analyzer] do not propagate Null<T> away
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jun 19, 2015
1 parent 0bc86e6 commit 12a52b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ module ConstPropagation = struct
with Not_found ->
-1

let rec can_be_inlined com v0 e = type_iseq v0.v_type e.etype && match e.eexpr with
let rec can_be_inlined com v0 e = type_iseq_strict v0.v_type e.etype && match e.eexpr with
| TConst ct ->
begin match ct with
| TThis | TSuper -> false
Expand Down
2 changes: 1 addition & 1 deletion tests/optimization/src/TestAnalyzer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class TestAnalyzer extends TestBase {
var b = B(0);
switch (b) {
case B(i):
assertEqualsConst(0, i);
assertEquals(0, i);
case A(_):
}
}
Expand Down
11 changes: 9 additions & 2 deletions type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ let map loop t =
a.a_fields <- fields;
t
| _ ->
TAnon {
TAnon {
a_fields = fields;
a_status = a.a_status;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ let apply_params cparams params t =
a.a_fields <- fields;
t
| _ ->
TAnon {
TAnon {
a_fields = fields;
a_status = a.a_status;
}
Expand Down Expand Up @@ -1447,6 +1447,13 @@ let type_iseq a b =
with
Unify_error _ -> false

let type_iseq_strict a b =
try
type_eq EqDoNotFollowNull a b;
true
with Unify_error _ ->
false

let unify_stack = ref []
let abstract_cast_stack = ref []
let unify_new_monos = ref []
Expand Down

0 comments on commit 12a52b2

Please sign in to comment.