Skip to content

Commit

Permalink
added @:keepSub: allow classes to force keeping their subclasses (fix…
Browse files Browse the repository at this point in the history
…ed issue HaxeFoundation#1005)
  • Loading branch information
Simn committed Jun 28, 2012
1 parent 38ac04c commit 0134196
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions std/flash/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ package flash;
}
#end

@:keep
class Boot extends flash.display.MovieClip {

static var tf : flash.text.TextField;
Expand Down
1 change: 1 addition & 0 deletions std/neko/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package neko;

@:keep
class Boot {

private static function __tmp_str() {
Expand Down
1 change: 1 addition & 0 deletions std/php/Boot.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package php;

@:keep
class Boot {
static var qtypes;
static var ttypes;
Expand Down
1 change: 1 addition & 0 deletions std/sys/db/Object.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
11 changes: 10 additions & 1 deletion typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 0134196

Please sign in to comment.