ソースを参照

[typer] disallow `@:overload(function)` + inline (#9364)

see #3846
Simon Krajewski 5 年 前
コミット
5a28ae0c23
2 ファイル変更3 行追加29 行削除
  1. 3 0
      src/typing/typeload.ml
  2. 0 29
      tests/unit/src/unit/issues/Issue3846.hx

+ 3 - 0
src/typing/typeload.ml

@@ -635,6 +635,9 @@ and init_meta_overloads ctx co cf =
 		| (Meta.Overload,[(EFunction (kind,f),p)],_)  ->
 			(match kind with FKNamed _ -> error "Function name must not be part of @:overload" p | _ -> ());
 			(match f.f_expr with Some (EBlock [], _) -> () | _ -> error "Overload must only declare an empty method body {}" p);
+			(match cf.cf_kind with
+				| Method MethInline -> error "Cannot @:overload inline function" p
+				| _ -> ());
 			let old = ctx.type_params in
 			(match cf.cf_params with
 			| [] -> ()

+ 0 - 29
tests/unit/src/unit/issues/Issue3846.hx

@@ -1,29 +0,0 @@
-package unit.issues;
-
-// they don't allow this insanity
-#if (!java && !cs)
-
-private class Extern {
-
-	@:keep
-	static public function mytest(a:Dynamic) {
-		return a;
-	}
-
-	@:overload( function (a:Int):Dynamic {})
-	extern
-	inline public static function test(a:String):Dynamic {
-		return mytest(a);
-	}
-}
-
-#end
-
-class Issue3846 extends Test {
-	#if (!java && !cs)
-	function test() {
-		eq("coucou", Extern.test("coucou"));
-		eq(1, Extern.test(1));
-	}
-	#end
-}