浏览代码

Merge pull request #4376 from andyli/extern-field-name

Allow extern to have field name that is used for both static and instance
Simon Krajewski 10 年之前
父节点
当前提交
b753b1b041
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      typeload.ml

+ 1 - 1
typeload.ml

@@ -2707,7 +2707,7 @@ module ClassInitializer = struct
 					()
 					()
 				| FKNormal ->
 				| FKNormal ->
 					let dup = if fctx.is_static then PMap.exists cf.cf_name c.cl_fields || has_field cf.cf_name c.cl_super else PMap.exists cf.cf_name c.cl_statics in
 					let dup = if fctx.is_static then PMap.exists cf.cf_name c.cl_fields || has_field cf.cf_name c.cl_super else PMap.exists cf.cf_name c.cl_statics in
-					if not cctx.is_native && dup then error ("Same field name can't be use for both static and instance : " ^ cf.cf_name) p;
+					if not cctx.is_native && not c.cl_extern && dup then error ("Same field name can't be use for both static and instance : " ^ cf.cf_name) p;
 					if List.mem AOverride f.cff_access then c.cl_overrides <- cf :: c.cl_overrides;
 					if List.mem AOverride f.cff_access then c.cl_overrides <- cf :: c.cl_overrides;
 					let is_var f = match cf.cf_kind with | Var _ -> true | _ -> false in
 					let is_var f = match cf.cf_kind with | Var _ -> true | _ -> false in
 					if PMap.mem cf.cf_name (if fctx.is_static then c.cl_statics else c.cl_fields) then
 					if PMap.mem cf.cf_name (if fctx.is_static then c.cl_statics else c.cl_fields) then