ソースを参照

don't allow super.dynamicMethod() (fixes #7638)

Aleksandr Kuzmenko 6 年 前
コミット
35ce1e760d

+ 6 - 1
src/typing/typer.ml

@@ -2323,7 +2323,12 @@ and type_call ctx e el (with_type:WithType.t) inline p =
 		else
 			type_expr ctx (ECall ((EField ((EField ((EConst (Ident "haxe"),p),"Log"),p),"trace"),p),[mk_to_string_meta e;infos]),p) WithType.NoValue
 	| (EField ((EConst (Ident "super"),_),_),_), _ ->
-		def()
+		(match def() with
+			| { eexpr = TCall ({ eexpr = TField (_, FInstance(_, _, { cf_kind = Method MethDynamic; cf_name = name })); epos = p }, _) } as e ->
+				ctx.com.error ("Cannot call super." ^ name ^ " since it's a dynamic method") p;
+				e
+			| e -> e
+		)
 	| (EField (e,"bind"),p), args ->
 		let e = type_expr ctx e WithType.value in
 		(match follow e.etype with

+ 15 - 0
tests/misc/projects/Issue7638/Main.hx

@@ -0,0 +1,15 @@
+class Main {
+	static function main() {}
+}
+
+class Parent {
+	dynamic function dynMethod() {}
+}
+
+class Child extends Parent {}
+
+class GrandChild extends Child {
+	override function dynMethod() {
+		super.dynMethod();
+	}
+}

+ 1 - 0
tests/misc/projects/Issue7638/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue7638/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:13: characters 3-18 : Cannot call super.dynMethod since it's a dynamic method