Parcourir la source

allow to inline override methods (fixed issue #120)

Nicolas Cannasse il y a 14 ans
Parent
commit
151f2a89cd
2 fichiers modifiés avec 9 ajouts et 4 suppressions
  1. 1 0
      doc/CHANGES.txt
  2. 8 4
      typeload.ml

+ 1 - 0
doc/CHANGES.txt

@@ -37,6 +37,7 @@
 	     (beta feature could not make in the final release)
 	all : added @:keep to prevent --dead-code-elimination of class/method
 	flash9 : fixed issues with loading a haXe SWF (boot_XXXX class extends flash.Boot)
+	all : allow to inline override methods (if the superclass method is not inlined already)
 
 2010-08-14: 2.06
 	neko : change serializer to be able to handle instances of basic classes from other modules

+ 8 - 4
typeload.ml

@@ -316,11 +316,15 @@ let check_overriding ctx c p () =
 					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass") p
 				else if f.cf_public <> f2.cf_public then
 					display_error ctx ("Field " ^ i ^ " has different visibility (public/private) than superclass one") p
-				else if f2.cf_kind = Method MethInline then
+				else (match f.cf_kind, f2.cf_kind with
+				| a, b when a = b -> ()
+				| Method MethInline, Method MethNormal ->
+					() (* allow to redefine a method as inlined *)
+				| _, Method MethInline ->
 					display_error ctx ("Field " ^ i ^ " is inlined and cannot be overridden") p
-				else if f2.cf_kind <> f.cf_kind then
-					display_error ctx ("Field " ^ i ^ " has different property access than in superclass") p
-				else try
+				| _ ->
+					display_error ctx ("Field " ^ i ^ " has different property access than in superclass") p);
+				try
 					let t = apply_params csup.cl_types params t in
 					valid_redefinition ctx f f.cf_type f2 t
 				with