Browse Source

always remove `@:generic` classes if they extend a type parameter (see #4092)

also temp fix type parameter classes appearing in the output
Simon Krajewski 10 years ago
parent
commit
c2d45eb8a4
1 changed files with 17 additions and 8 deletions
  1. 17 8
      filters.ml

+ 17 - 8
filters.ml

@@ -762,14 +762,23 @@ let save_class_state ctx t = match t with
 (* PASS 2 begin *)
 (* PASS 2 begin *)
 
 
 let is_removable_class c =
 let is_removable_class c =
-	c.cl_kind = KGeneric &&
-	(Meta.has Meta.Remove c.cl_meta ||
-	List.exists (fun (_,t) -> match follow t with
-		| TInst(c,_) ->
-			Codegen.has_ctor_constraint c
-		| _ ->
-			false
-	) c.cl_params)
+	match c.cl_kind with
+	| KGeneric ->
+		(Meta.has Meta.Remove c.cl_meta ||
+		(match c.cl_super with
+			| Some ({cl_kind = KTypeParameter _},_) -> true
+			| _ -> false) ||
+		List.exists (fun (_,t) -> match follow t with
+			| TInst(c,_) ->
+				Codegen.has_ctor_constraint c
+			| _ ->
+				false
+		) c.cl_params)
+	| KTypeParameter _ ->
+		(* this shouldn't happen, have to investigate (see #4092) *)
+		true
+	| _ ->
+		false
 
 
 let remove_generic_base ctx t = match t with
 let remove_generic_base ctx t = match t with
 	| TClassDecl c when is_removable_class c ->
 	| TClassDecl c when is_removable_class c ->