Explorar o código

fixed getInstanceFields duplicates

Nicolas Cannasse %!s(int64=17) %!d(string=hai) anos
pai
achega
8fd220b2cc
Modificáronse 2 ficheiros con 13 adicións e 6 borrados
  1. 1 0
      doc/CHANGES.txt
  2. 12 6
      std/Type.hx

+ 1 - 0
doc/CHANGES.txt

@@ -37,6 +37,7 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	added support for "g" modifier in EReg for PHP
 	PHP now generates __toString for classes that have toString defined
 	implemented php.Lib.getClasses()
+	fixed duplicate fields in Type.getInstanceFields on subclass
 
 2008-07-28: 2.0
 	fixed current package bug in inherited constructor type

+ 12 - 6
std/Type.hx

@@ -427,17 +427,23 @@ class Type {
 			return untyped __php__("array_values(array_unique($r))");
 		#else
 			var a = Reflect.fields(untyped c.prototype);
-			c = untyped c.__super__;
-			while( c != null ) {
-				a = a.concat(Reflect.fields(untyped c.prototype));
+			#if js
+				a.remove("__class__");
+			#else
 				c = untyped c.__super__;
-			}
-			while( a.remove(__unprotect__("__class__")) ) {
+				while( c != null ) {
+					for( f in Reflect.fields(untyped c.prototype) ) {
+						a.remove(f);
+						a.push(f);
+					}
+					c = untyped c.__super__;
+				}
+				a.remove("__class__");
 				#if neko
 				a.remove("__serialize");
 				a.remove("__string");
 				#end
-			}
+			#end
 			return a;
 		#end
 	}