فهرست منبع

[analyzer] do not propagate `Null<T>` away

Simon Krajewski 10 سال پیش
والد
کامیت
12a52b2fcd
3فایلهای تغییر یافته به همراه11 افزوده شده و 4 حذف شده
  1. 1 1
      analyzer.ml
  2. 1 1
      tests/optimization/src/TestAnalyzer.hx
  3. 9 2
      type.ml

+ 1 - 1
analyzer.ml

@@ -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

+ 1 - 1
tests/optimization/src/TestAnalyzer.hx

@@ -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(_):
 		}
 	}

+ 9 - 2
type.ml

@@ -489,7 +489,7 @@ let map loop t =
 				a.a_fields <- fields;
 				t
 			| _ ->
-	 			TAnon {
+				TAnon {
 					a_fields = fields;
 					a_status = a.a_status;
 				}
@@ -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;
 					}
@@ -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 []