Browse Source

added @:keepSub: allow classes to force keeping their subclasses (fixed issue #1005)

Simon Krajewski 13 years ago
parent
commit
0134196095
5 changed files with 14 additions and 1 deletions
  1. 1 0
      std/flash/Boot.hx
  2. 1 0
      std/neko/Boot.hx
  3. 1 0
      std/php/Boot.hx
  4. 1 0
      std/sys/db/Object.hx
  5. 10 1
      typer.ml

+ 1 - 0
std/flash/Boot.hx

@@ -44,6 +44,7 @@ package flash;
 }
 #end
 
+@:keep
 class Boot extends flash.display.MovieClip {
 
 	static var tf : flash.text.TextField;

+ 1 - 0
std/neko/Boot.hx

@@ -24,6 +24,7 @@
  */
 package neko;
 
+@:keep
 class Boot {
 
 	private static function __tmp_str() {

+ 1 - 0
std/php/Boot.hx

@@ -1,5 +1,6 @@
 package php;
 
+@:keep
 class Boot {
 	static var qtypes;
 	static var ttypes;

+ 1 - 0
std/sys/db/Object.hx

@@ -28,6 +28,7 @@ package sys.db;
 	SPOD Object : the persistent object base type. See the tutorial on haXe
 	website to learn how to use SPOD.
 **/
+@:keepSub
 @:autoBuild(sys.db.SpodMacros.macroBuild()) @:skipFields
 class Object {
 

+ 10 - 1
typer.ml

@@ -2310,7 +2310,16 @@ let dce_check_metadata ctx meta =
 	) meta
 
 let dce_check_class ctx c =
-	let keep_whole_class = c.cl_interface || has_meta ":keep" c.cl_meta || (match c.cl_path with ["php"],"Boot" | ["neko"],"Boot" | ["flash"],"Boot" | [],"Array" | [],"String" -> not (platform ctx.com Js) | _ -> false)  in
+	let rec super_forces_keep c = match c.cl_super with
+		| Some (csup,_) when has_meta ":keepSub" csup.cl_meta -> true
+		| Some (csup,_) -> super_forces_keep csup
+		| _ -> false
+	in
+	let keep_whole_class = c.cl_interface
+		|| has_meta ":keep" c.cl_meta
+		|| (match c.cl_path with [],"Array" | [],"String" -> not (platform ctx.com Js) | _ -> false)
+		|| super_forces_keep c
+	in
 	let keep stat f =
 		keep_whole_class
 		|| (c.cl_extern && (match f.cf_kind with Method MethInline -> false | _ -> true))