Nicolas Cannasse 9 vuotta sitten
vanhempi
commit
02f0f0d1a7
2 muutettua tiedostoa jossa 9 lisäystä ja 15 poistoa
  1. 5 12
      genhl.ml
  2. 4 3
      std/hl/types/BaseType.hx

+ 5 - 12
genhl.ml

@@ -734,12 +734,6 @@ let rec to_type ?tref ctx t =
 			ctx.anons_cache <- (a,t) :: ctx.anons_cache;
 			let fields = PMap.fold (fun cf acc ->
 				match cf.cf_kind with
-				| Var { v_read = AccNo } | Var { v_write = AccNo } ->
-					(*
-						if there's read-only/write-only fields, it will allow variance, so let's
-						handle the field access as fully Dynamic
-					*)
-					acc
 				| Var _ when has_meta Meta.Optional cf.cf_meta ->
 					(*
 						if it's optional it might not be present, handle the field access as fully Dynamic
@@ -2934,9 +2928,8 @@ let generate_static_init ctx =
 					List.iter check ctx.com.types;
 					!classes
 				in
-				(match gather_implements() with
-				| [] -> ()
-				| l ->
+				if c.cl_interface then begin
+					let l = gather_implements() in
 					let ra = alloc_tmp ctx HArray in
 					let rt = alloc_tmp ctx HType in
 					op ctx (OType (rt, HType));
@@ -2945,8 +2938,8 @@ let generate_static_init ctx =
 						op ctx (OType (rt, to_type ctx (TInst (intf,[]))));
 						op ctx (OSetArray (ra, reg_int ctx i, rt));
 					) l;
-					op ctx (OSetField (rc,index "__implementedBy__",ra)));
-
+					op ctx (OSetField (rc,index "__implementedBy__",ra));
+				end;
 
 				(* register static funs *)
 
@@ -3250,7 +3243,7 @@ let check code =
 				can_jump delta
 			| OJEq (a,b,delta) | OJNotEq (a,b,delta) ->
 				(match rtype a, rtype b with
-				| HObj _, HObj _ -> ()
+				| (HObj _ | HVirtual _), (HObj _ | HVirtual _) -> ()
 				| ta, tb when safe_cast tb ta -> ()
 				| _ -> reg a (rtype b));
 				can_jump delta

+ 4 - 3
std/hl/types/BaseType.hx

@@ -7,10 +7,11 @@ class BaseType {
 	public var __implementedBy__ : NativeArray<Type>;
 	public function check( v : Dynamic ) {
 		var t = Type.getDynamic(v);
-		if( t.safeCast(__type__) )
-			return true;
-		if( __implementedBy__ == null )
+		if( __implementedBy__ == null ) {
+			if( t.safeCast(__type__) )
+				return true;		
 			return false;
+		}
 		for( i in __implementedBy__ )
 			if( t.safeCast(i) )
 				return true;