浏览代码

allow loading of .[platform].hx when .hx exists

Nicolas Cannasse 9 年之前
父节点
当前提交
83a271ceaf
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      src/typing/common.ml

+ 8 - 3
src/typing/common.ml

@@ -1006,9 +1006,14 @@ let find_file ctx f =
 			| [] -> loop true [""]
 			| [] -> loop true [""]
 			| p :: l ->
 			| p :: l ->
 				let file = p ^ f in
 				let file = p ^ f in
-				if Sys.file_exists file then
-					file
-				else
+				if Sys.file_exists file then begin
+					(try
+						let ext = String.rindex file '.' in
+						let file_pf = String.sub file 0 (ext + 1) ^ platform_name ctx.platform ^ String.sub file ext (String.length file - ext) in
+						if not (defined ctx Define.CoreApi) && Sys.file_exists file_pf then file_pf else file
+					with Not_found ->
+						file)
+				end else
 					loop (had_empty || p = "") l
 					loop (had_empty || p = "") l
 		in
 		in
 		let r = (try Some (loop false ctx.class_path) with Not_found -> None) in
 		let r = (try Some (loop false ctx.class_path) with Not_found -> None) in