Explorar el Código

[typer] don't look up static extensions on `super` (closes #3607)

Simon Krajewski hace 8 años
padre
commit
0493f857c3

+ 4 - 1
src/typing/typer.ml

@@ -1367,7 +1367,10 @@ and type_field ?(resume=false) ctx e i p mode =
 			if not (can_access ctx c f false) && not ctx.untyped then display_error ctx ("Cannot access private field " ^ i) p;
 			field_access ctx mode f (match c2 with None -> FAnon f | Some (c,tl) -> FInstance (c,tl,f)) (apply_params c.cl_params params t) e p
 		with Not_found -> try
-			using_field ctx mode e i p
+			begin match e.eexpr with
+				| TConst TSuper -> raise Not_found
+				| _ -> using_field ctx mode e i p
+			end
 		with Not_found -> try
 			loop_dyn c params
 		with Not_found -> try

+ 24 - 0
tests/misc/projects/Issue3607/Main.hx

@@ -0,0 +1,24 @@
+using Main.Tools;
+
+class Tools {
+	@:pure(false)
+    public static function f(b:Base) {}
+
+	public static var test:String;
+}
+
+class Base {
+	public function new() { }
+}
+
+class Child extends Base {
+    public function a() {
+        super.f();
+    }
+}
+
+class Main {
+	static public function main() {
+		new Child().a();
+	}
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:16: characters 9-16 : Base has no field f