Browse Source

forbid usage of type parameters in static functions

Nicolas Cannasse 18 years ago
parent
commit
c51b7db2da
3 changed files with 6 additions and 5 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 3 3
      std/flash/geom/Point.hx
  3. 2 2
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -9,6 +9,7 @@
 	fixed Flash9 statics slots (FP 9,0,60 compatibility)
 	fixed Flash9 Type.getClassName
 	optional enums arguments on Flash9 are now automatically Null
+	forbid usage of type parameters in static functions
 
 2007-07-25: 1.14
 	fixed no error when invalid "catch" expression

+ 3 - 3
std/flash/geom/Point.hx

@@ -20,8 +20,8 @@ extern class Point<T> {
 	function clone() : Point<T>;
 	function toString() : String;
 
-	static function distance( p1 : Point<T>, p2 : Point<T> ) : T;
-	static function interpolate( p1 : Point<T>, p2 : Point<T>, f : T ) : Point<T>;
-	static function polar( dist : T, angle : T ) : Point<T>;
+	static function distance<T>( p1 : Point<T>, p2 : Point<T> ) : T;
+	static function interpolate<T>( p1 : Point<T>, p2 : Point<T>, f : T ) : Point<T>;
+	static function polar<T>( dist : T, angle : T ) : Point<T>;
 
 }

+ 2 - 2
typer.ml

@@ -2317,16 +2317,16 @@ let init_class ctx c p herits fields =
 					type_type_params ctx ([],name) p (n,[])
 				| _ -> error "This notation is not allowed because it can't be checked" p
 			) params in
+			let stat = List.mem AStatic access in
 			let ctx = { ctx with
 				curclass = c;
 				curmethod = name;
 				tthis = tthis;
-				type_params = params @ ctx.type_params;
+				type_params = if stat then params  else params @ ctx.type_params;
 			} in
 			let ret = type_opt ctx p f.f_type in
 			let args = List.map (fun (name,opt,t) -> name , opt, type_opt ~param:opt ctx p t) f.f_args in
 			let t = TFun (args,ret) in
-			let stat = List.mem AStatic access in
 			let constr = (name = "new") in
 			if c.cl_interface && not stat && (match f.f_expr with EBlock [] , _ -> false | _ -> true) then error "An interface method cannot have a body" p;
 			if constr then (match f.f_type with