Browse Source

allow enum matching on abstracts with underlying enum types (fixed issue #1556)

Simon Krajewski 12 years ago
parent
commit
32b8401880
1 changed files with 2 additions and 2 deletions
  1. 2 2
      matcher.ml

+ 2 - 2
matcher.ml

@@ -181,7 +181,7 @@ let mk_subs st con =
 	match con.c_def with
 	| CFields (_,fl) -> List.map (fun (s,cf) -> mk_st (SField(st,s)) (map cf.cf_type) st.st_pos) fl
 	| CEnum (en,({ef_type = TFun _} as ef)) ->
-		let pl = match follow con.c_type with TEnum(_,pl) -> pl | _ -> assert false in
+		let pl = match follow con.c_type with TEnum(_,pl) | TAbstract({a_this = TEnum(_)},pl)-> pl | _ -> assert false in
 		begin match apply_params en.e_types pl (monomorphs ef.ef_params ef.ef_type) with
 			| TFun(args,r) ->
 				ExtList.List.mapi (fun i (_,_,t) ->
@@ -928,7 +928,7 @@ let rec to_typed_ast mctx dt =
 		end
 	| Switch(st,cases) ->
 		match follow st.st_type with
-		| TEnum(en,pl) -> to_enum_switch mctx en pl st cases
+		| TEnum(en,pl) | TAbstract({a_this = TEnum(en,_)},pl) -> to_enum_switch mctx en pl st cases
 		| TInst({cl_path = [],"Array"},[t]) -> to_array_switch mctx t st cases
 		| t -> to_value_switch mctx t st cases