Przeglądaj źródła

add @:enum metadata to lifted abstract constructors and fix completion accordingly (closes #2422)

Simon Krajewski 11 lat temu
rodzic
commit
9f4ad1c79f
2 zmienionych plików z 3 dodań i 2 usunięć
  1. 1 0
      std/haxe/macro/Build.hx
  2. 2 2
      typer.ml

+ 1 - 0
std/haxe/macro/Build.hx

@@ -56,6 +56,7 @@ class Build {
 					var tE = Context.typeof(e);
 					if (!Context.unify(tE, tThis)) Context.error('${tE.toString()} should be ${tThis.toString()}', e.pos);
 					field.meta.push({name: ":impl", params: [], pos: field.pos});
+					field.meta.push({name: ":enum", params: [], pos: field.pos});
 					field.kind = FVar(tF.toComplexType(), macro cast $e);
 				case _:
 			}

+ 2 - 2
typer.ml

@@ -3071,7 +3071,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 				if Meta.has Meta.CoreApi c.cl_meta then merge_core_doc c;
 				ctx.m.module_using <- c :: ctx.m.module_using;
 				PMap.fold (fun f acc ->
-					if f.cf_name <> "_new" && can_access ctx c f true && Meta.has Meta.Impl f.cf_meta then begin
+					if f.cf_name <> "_new" && can_access ctx c f true && Meta.has Meta.Impl f.cf_meta && not (Meta.has Meta.Enum f.cf_meta) then begin
 						let f = prepare_using_field f in
 						let t = apply_params a.a_types pl (follow f.cf_type) in
 						PMap.add f.cf_name { f with cf_public = true; cf_type = opt_type t } acc
@@ -3085,7 +3085,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 					let is_abstract_impl = match c.cl_kind with KAbstractImpl _ -> true | _ -> false in
 					let pm = match c.cl_constructor with None -> PMap.empty | Some cf -> PMap.add "new" cf PMap.empty in
 					PMap.fold (fun f acc ->
-						if can_access ctx c f true && (not is_abstract_impl || not (Meta.has Meta.Impl f.cf_meta)) then
+						if can_access ctx c f true && (not is_abstract_impl || not (Meta.has Meta.Impl f.cf_meta) || Meta.has Meta.Enum f.cf_meta) then
 							PMap.add f.cf_name { f with cf_public = true; cf_type = opt_type f.cf_type } acc else acc
 					) a.a_fields pm
 				| _ ->