Forráskód Böngészése

change `is_parent csup c` into `extends c csup`

Aleksandr Kuzmenko 5 éve
szülő
commit
09cfe9f63c

+ 1 - 1
src/context/typecore.ml

@@ -449,7 +449,7 @@ let rec can_access ctx ?(in_overload=false) c cf stat =
 			has Meta.Access ctx.curclass ctx.curfield ((make_path c cf), true)
 			|| (
 				(* if our common ancestor declare/override the field, then we can access it *)
-				let allowed f = is_parent c ctx.curclass || (List.exists (has Meta.Allow c f) !cur_paths) in
+				let allowed f = extends ctx.curclass c || (List.exists (has Meta.Allow c f) !cur_paths) in
 				if is_constr
 				then (match c.cl_constructor with
 					| Some cf ->

+ 3 - 3
src/core/tFunctions.ml

@@ -203,12 +203,12 @@ let t_infos t : tinfos =
 
 let t_path t = (t_infos t).mt_path
 
-let rec is_parent csup c =
-	if c == csup || List.exists (fun (i,_) -> is_parent csup i) c.cl_implements then
+let rec extends c csup =
+	if c == csup || List.exists (fun (i,_) -> extends i csup) c.cl_implements then
 		true
 	else match c.cl_super with
 		| None -> false
-		| Some (c,_) -> is_parent csup c
+		| Some (c,_) -> extends c csup
 
 let add_descendant c descendant =
 	c.cl_descendants <- descendant :: c.cl_descendants

+ 1 - 1
src/generators/genphp7.ml

@@ -3398,7 +3398,7 @@ class class_builder ctx (cls:tclass) =
 								if probably_descendant == iface then
 									false
 								else
-									is_parent iface probably_descendant
+									extends probably_descendant iface
 							)
 							cls.cl_implements
 						)

+ 2 - 2
src/typing/fields.ml

@@ -134,7 +134,7 @@ let get_constructor ctx c params p =
 
 let check_constructor_access ctx c f p =
 	if (Meta.has Meta.CompilerGenerated f.cf_meta) then display_error ctx (error_msg (No_constructor (TClassDecl c))) p;
-	if not (can_access ctx c f true || is_parent c ctx.curclass) && not ctx.untyped then display_error ctx (Printf.sprintf "Cannot access private constructor of %s" (s_class_path c)) p
+	if not (can_access ctx c f true || extends ctx.curclass c) && not ctx.untyped then display_error ctx (Printf.sprintf "Cannot access private constructor of %s" (s_class_path c)) p
 
 let check_no_closure_meta ctx fa mode p =
 	if mode <> MCall && not (DisplayPosition.display_position#enclosed_in p) then begin
@@ -201,7 +201,7 @@ let field_access ctx mode f fmode t e p =
 		match (match mode with MGet | MCall -> v.v_read | MSet -> v.v_write) with
 		| AccNo when not (Meta.has Meta.PrivateAccess ctx.meta) ->
 			(match follow e.etype with
-			| TInst (c,_) when is_parent c ctx.curclass || can_access ctx c { f with cf_flags = unset_flag f.cf_flags (int_of_class_field_flag CfPublic) } false -> normal()
+			| TInst (c,_) when extends ctx.curclass c || can_access ctx c { f with cf_flags = unset_flag f.cf_flags (int_of_class_field_flag CfPublic) } false -> normal()
 			| TAnon a ->
 				(match !(a.a_status) with
 				| Opened when mode = MSet ->

+ 2 - 2
src/typing/typeloadCheck.ml

@@ -326,7 +326,7 @@ module Inheritance = struct
 	let check_extends ctx c t p = match follow t with
 		| TInst (csup,params) ->
 			if is_basic_class_path csup.cl_path && not (c.cl_extern && csup.cl_extern) then error "Cannot extend basic class" p;
-			if is_parent c csup then error "Recursive class" p;
+			if extends csup c then error "Recursive class" p;
 			begin match csup.cl_kind with
 				| KTypeParameter _ ->
 					if is_generic_parameter ctx csup then error "Extending generic type parameters is no longer allowed in Haxe 4" p;
@@ -475,7 +475,7 @@ module Inheritance = struct
 					c.cl_array_access <- Some t;
 					(fun () -> ())
 				| TInst (intf,params) ->
-					if is_parent c intf then error "Recursive class" p;
+					if extends intf c then error "Recursive class" p;
 					if c.cl_interface then error "Interfaces cannot implement another interface (use extends instead)" p;
 					if not intf.cl_interface then error "You can only implement an interface" p;
 					c.cl_implements <- (intf, params) :: c.cl_implements;