Dan Korostelev 6 years ago
parent
commit
05420d3f15
2 changed files with 20 additions and 0 deletions
  1. 1 0
      src/typing/forLoop.ml
  2. 19 0
      tests/unit/src/unit/issues/Issue8221.hx

+ 1 - 0
src/typing/forLoop.ml

@@ -128,6 +128,7 @@ module IterationKind = struct
 					let t = match tl with [t] -> t | _ -> raise Not_found in
 					let t = match tl with [t] -> t | _ -> raise Not_found in
 					IteratorCustom(get_next_array_element,get_length),e,t
 					IteratorCustom(get_next_array_element,get_length),e,t
 			end with Not_found -> try
 			end with Not_found -> try
+				if PMap.exists "iterator" c.cl_statics then raise Not_found;
 				let v_tmp = gen_local ctx e.etype e.epos in
 				let v_tmp = gen_local ctx e.etype e.epos in
 				let e_tmp = make_local v_tmp v_tmp.v_pos in
 				let e_tmp = make_local v_tmp v_tmp.v_pos in
 				let acc_next = type_field ~resume:true ctx e_tmp "next" p MCall in
 				let acc_next = type_field ~resume:true ctx e_tmp "next" p MCall in

+ 19 - 0
tests/unit/src/unit/issues/Issue8221.hx

@@ -0,0 +1,19 @@
+package unit.issues;
+
+private abstract A(Dynamic) {
+	public function iterator():Iterator<String> {
+		var done = false;
+		return {
+			hasNext: () -> !done,
+			next: () -> {done = true; "works";}
+		};
+	}
+	@:op(a.b) function resolve(name:String):A throw "nope";
+}
+
+class Issue8221 extends unit.Test {
+	function test() {
+		var a:A = null;
+		aeq(["works"], [for (v in a) v]);
+	}
+}