Kaynağa Gözat

respect anon_status when identifying

Simon Krajewski 1 yıl önce
ebeveyn
işleme
db4e612a1f
1 değiştirilmiş dosya ile 35 ekleme ve 19 silme
  1. 35 19
      src/typing/tanon_identification.ml

+ 35 - 19
src/typing/tanon_identification.ml

@@ -135,29 +135,26 @@ object(self)
 		in
 		loop td.t_type
 
-	method identify (accept_anons : bool) (t : Type.t) =
-		match t with
-		| TType(td,tl) ->
-			begin try
-				Some (Hashtbl.find pfms td.t_path)
-			with Not_found ->
-				self#identify accept_anons (apply_typedef td tl)
-			end
-		| TMono {tm_type = Some t} ->
-			self#identify accept_anons t
-		| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
-			self#identify accept_anons (Abstract.get_underlying_type a tl)
-		| TAbstract({a_path=([],"Null")},[t]) ->
-			self#identify accept_anons t
-		| TLazy f ->
-			self#identify accept_anons (lazy_type f)
-		| TAnon an when accept_anons && not (PMap.is_empty an.a_fields) ->
+	method identity_anon (an : tanon) =
+		let make_pfm path = {
+			pfm_path = path;
+			pfm_params = [];
+			pfm_fields = an.a_fields;
+			pfm_converted = None;
+			pfm_arity = count_fields an.a_fields;
+		} in
+		match !(an.a_status) with
+		| ClassStatics {cl_path = path} | EnumStatics {e_path = path} | AbstractStatics {a_path = path} ->
+			let pfm = make_pfm path in
+			self#add_pfm path pfm;
+			Some pfm
+		| _ ->
 			let arity = PMap.fold (fun cf i ->
 				replace_mono cf.cf_type;
 				i + 1
 			) an.a_fields 0 in
 			begin try
-				Some (self#find_compatible arity t)
+				Some (self#find_compatible arity (TAnon an))
 			with Not_found ->
 				let id = num in
 				num <- num + 1;
@@ -171,7 +168,26 @@ object(self)
 				} in
 				self#add_pfm path pfm;
 				Some pfm
-			end;
+			end
+
+	method identify (accept_anons : bool) (t : Type.t) =
+		match t with
+		| TType(td,tl) ->
+			begin try
+				Some (Hashtbl.find pfms td.t_path)
+			with Not_found ->
+				self#identify accept_anons (apply_typedef td tl)
+			end
+		| TMono {tm_type = Some t} ->
+			self#identify accept_anons t
+		| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
+			self#identify accept_anons (Abstract.get_underlying_type a tl)
+		| TAbstract({a_path=([],"Null")},[t]) ->
+			self#identify accept_anons t
+		| TLazy f ->
+			self#identify accept_anons (lazy_type f)
+		| TAnon an when accept_anons && not (PMap.is_empty an.a_fields) ->
+			self#identity_anon an
 		| _ ->
 			None
 end