Simon Krajewski 13 ani în urmă
părinte
comite
c2c5535061
3 a modificat fișierele cu 25 adăugiri și 5 ștergeri
  1. 2 0
      doc/CHANGES.txt
  2. 7 5
      optimizer.ml
  3. 16 0
      tests/unit/TestType.hx

+ 2 - 0
doc/CHANGES.txt

@@ -1,5 +1,6 @@
 2012-xx-xx: 2.10
 	as3 : many small fixes
+	as3 : support for metadata and resources
 	js/flash : compile StringBuf as String for better performance
 	all : allow function calls as field variable initialization if a constant expression is returned
 	all : many DCE fixes
@@ -51,6 +52,7 @@
 	all : allow to inline functions containing other functions
 	xml : added metadata output to xml generator
 	macro : added macro <expr> reification
+	all : renamed type(e) to $type(e)
 
 2012-04-14: 2.09
 	all : optimized const == const and const != const (with different const types)

+ 7 - 5
optimizer.ml

@@ -344,11 +344,13 @@ let rec type_inline ctx cf f ethis params tret p force =
 			with Unify_error _ ->
 				mk (TCast (e,None)) tret e.epos)
 		in
-		let e = (match e.eexpr, init with
-			| TBlock [e] , None -> wrap e
-			| _ , None -> wrap e
-			| TBlock l, Some init -> mk (TBlock (init :: l)) tret e.epos
-			| _, Some init -> mk (TBlock [init;e]) tret e.epos
+		let e = (match e.eexpr, init, tret with
+			| _, None, TEnum ({ e_path = [],"Void" },_) ->
+				{e with etype = tret}
+			| TBlock [e] , None, _ -> wrap e
+			| _ , None, _ -> wrap e
+			| TBlock l, Some init, _ -> mk (TBlock (init :: l)) tret e.epos
+			| _, Some init, _ -> mk (TBlock [init;e]) tret e.epos
 		) in
 		(* we need to replace type-parameters that were used in the expression *)
 		if not has_params then

+ 16 - 0
tests/unit/TestType.hx

@@ -480,4 +480,20 @@ class TestType extends Test {
 		eq(InitBase.st, String);
 		eq(InitBase.sinline, 60000.);
 	}
+	
+	function testInline()
+	{
+		#if !macro
+		typedAs(inlineTest1([1]), Void);
+		typedAs(inlineTest2([1]), Void);
+		#end
+	}
+	
+	inline function inlineTest1<T>(map:Array<T>) {
+		map[0];
+	}
+	
+	inline function inlineTest2(map:Array<Dynamic>) {
+		map[0];
+	}
 }