Browse Source

fix `using` picking up non-static abstract functions (closes #5888)

Simon Krajewski 8 years ago
parent
commit
9dc9a7af07

+ 1 - 0
extra/CHANGES.txt

@@ -2,6 +2,7 @@
 
 
 	Bugfixes:
 	Bugfixes:
 
 
+	all : fixed `using` picking up non-static abstract functions (#5888)
 	all : fixed issue with side-effect detection when optimizing (#5911)
 	all : fixed issue with side-effect detection when optimizing (#5911)
 	php7 : Allow user-defined modules in `php` package (#5921)
 	php7 : Allow user-defined modules in `php` package (#5921)
 	php7 : Dereference some of `php.Syntax` methods if required (#5923)
 	php7 : Dereference some of `php.Syntax` methods if required (#5923)

+ 1 - 1
src/typing/typer.ml

@@ -1131,7 +1131,7 @@ let rec using_field ctx mode e i p =
 	| (c,pc) :: l ->
 	| (c,pc) :: l ->
 		try
 		try
 			let cf = PMap.find i c.cl_statics in
 			let cf = PMap.find i c.cl_statics in
-			if Meta.has Meta.NoUsing cf.cf_meta || not (can_access ctx c cf true) then raise Not_found;
+			if Meta.has Meta.NoUsing cf.cf_meta || not (can_access ctx c cf true) || (Meta.has Meta.Impl cf.cf_meta) then raise Not_found;
 			let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 			let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 			let map = apply_params cf.cf_params monos in
 			let map = apply_params cf.cf_params monos in
 			let t = map cf.cf_type in
 			let t = map cf.cf_type in

+ 11 - 0
tests/misc/projects/Issue5888/Main.hx

@@ -0,0 +1,11 @@
+using Main;
+
+class Main {
+	static function main() {
+		0.bar();   //Should not compile.
+	}
+}
+
+abstract Foo(Int) {
+	public function bar() {};
+}

+ 3 - 0
tests/misc/projects/Issue5888/compile-fail.hxml

@@ -0,0 +1,3 @@
+-main Main
+--no-output
+-js js.js

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

@@ -0,0 +1 @@
+Main.hx:5: characters 8-13 : Int has no field bar