Browse Source

prioritize @:to/@:from over to/from for abstract casts

Simon Krajewski 11 năm trước cách đây
mục cha
commit
c847720631
2 tập tin đã thay đổi với 8 bổ sung4 xóa
  1. 2 2
      std/UInt.hx
  2. 6 2
      typeload.ml

+ 2 - 2
std/UInt.hx

@@ -32,7 +32,7 @@
 	Simulate it for other platforms.
 **/
 @:coreType
-abstract UInt from Int {
+abstract UInt from Int to Int {
 
 	@:op(A + B) private static inline function add(a:UInt, b:UInt):UInt {
 		return a.toInt() + b.toInt();
@@ -213,7 +213,7 @@ abstract UInt from Int {
 		}
 	}
 
-	@:to private inline function toInt():Int {
+	private inline function toInt():Int {
 		return cast this;
 	}
 

+ 6 - 2
typeload.ml

@@ -2104,8 +2104,12 @@ let init_class ctx c p context_init herits fields =
 	) fields;
 	(match c.cl_kind with
 	| KAbstractImpl a ->
-		a.a_to <- List.rev a.a_to;
-		a.a_from <- List.rev a.a_from;
+		a.a_to <- List.stable_sort (fun (_,cfo1) (_,cfo2) ->
+			if cfo1 = None then 1 else if cfo2 = None then -1 else 0
+		) (List.rev a.a_to);
+		a.a_from <- List.stable_sort (fun (_,cfo1) (_,cfo2) ->
+			if cfo1 = None then 1 else if cfo2 = None then -1 else 0
+		) (List.rev a.a_from);
 		a.a_ops <- List.rev a.a_ops;
 		a.a_unops <- List.rev a.a_unops;
 	| _ -> ());