Browse Source

don't generate __init__ method for extern classs if it's not used (closes #3050)

Dan Korostelev 11 years ago
parent
commit
0641d27b35
3 changed files with 4 additions and 1 deletions
  1. 0 1
      dce.ml
  2. 3 0
      extra/CHANGES.txt
  3. 1 0
      std/js/_std/Math.hx

+ 0 - 1
dce.ml

@@ -56,7 +56,6 @@ let keep_whole_class dce c =
 	|| super_forces_keep c
 	|| (match c with
 		| { cl_path = ([],("Math"|"Array"))} when dce.com.platform = Js -> false
-		| { cl_extern = true }
 		| { cl_path = ["flash";"_Boot"],"RealBoot" } -> true
 		| { cl_path = [],"String" }
 		| { cl_path = [],"Array" } -> not (dce.com.platform = Js)

+ 3 - 0
extra/CHANGES.txt

@@ -22,6 +22,9 @@
 	cpp : fixed issue with the side-effect handler
 	cpp : fixed issue with NativeArray in --no-inline mode
 	php : fixed issue with invalid references for closures in for-loops
+	all : fixed __init__ methods of extern classes being generated even if the class is not used (but imported).
+	      this change may break existing code that relies on that bug. to force extern class __init__ generation,
+	      use the @:keepInit class-level metadata
 
 	General improvements and optimizations:
 

+ 1 - 0
std/js/_std/Math.hx

@@ -23,6 +23,7 @@ package;
 
 // Can't enable @:coreApi because some fields are now inline getters
 // @:coreApi
+@:keepInit
 extern class Math
 {
 	static var PI(default,null) : Float;