Fix issue in join where the origin of a variable would be lost in a loop.

Reviewed By: sblackshear

Differential Revision: D3340039

fbshipit-source-id: 2e00d3d
master
Cristiano Calcagno 9 years ago committed by Facebook Github Bot 5
parent e3e80dd2f0
commit 56cfac14da

@ -84,7 +84,7 @@ let range_add_locs (typ, ta, locs1) locs2 =
let locs' = locs_join locs1 locs2 in
(typ, ta, locs')
(** Join m2 to m1 if there are no inconsistencies, otherwise return t1. *)
(** Join m2 to m1 if there are no inconsistencies, otherwise return m1. *)
let map_join m1 m2 =
let tjoined = ref m1 in
let range_join (typ1, ta1, locs1) (typ2, ta2, locs2) =
@ -101,11 +101,7 @@ let map_join m1 m2 =
| None -> ()
| Some range' -> tjoined := M.add exp2 range' !tjoined)
with Not_found ->
let (t2, ta2, locs2) = range2 in
let range2' =
let ta2' = TypeAnnotation.with_origin ta2 TypeOrigin.Undef in
(t2, ta2', locs2) in
tjoined := M.add exp2 range2' !tjoined in
tjoined := M.add exp2 range2 !tjoined in
let missing_rhs exp1 range1 = (* handle elements missing in the rhs *)
try
ignore (M.find exp1 m2)
@ -123,6 +119,10 @@ let map_join m1 m2 =
)
let join ext t1 t2 =
if Config.from_env_variable "ERADICATE_TRACE"
then L.stderr "@.@.**********join@.-------@.%a@.------@.%a@.********@.@."
(pp ext) t1
(pp ext) t2;
{
map = map_join t1.map t2.map;
extension = ext.join t1.extension t2.extension;

@ -357,6 +357,14 @@ class NestedFieldAccess {
}
}
void testMapContainsKeyInsideWhileLoop (java.util.Map<Integer, String> m) {
while (true) {
if (m.containsKey(3)) {
m.get(3).isEmpty();
}
}
}
void testImmutableMapContainsKey (com.google.common.collect.ImmutableMap<Integer, String> m) {
if (m.containsKey(3)) {
m.get(3).isEmpty();

Loading…
Cancel
Save