Преглед на файлове

[generic] consider @:genericClassPerMethod when determining dependencies

closes #10635
Simon Krajewski преди 3 години
родител
ревизия
d9bd070a64
променени са 2 файла, в които са добавени 20 реда и са изтрити 1 реда
  1. 2 1
      src/typing/generic.ml
  2. 18 0
      tests/server/src/cases/display/issues/Issue10635.hx

+ 2 - 1
src/typing/generic.ml

@@ -405,7 +405,6 @@ let type_generic_function ctx fa fcc with_type p =
 			else
 				error ("Cannot specialize @:generic because the generated function name is already used: " ^ name) p *)
 		with Not_found ->
-			set_type_parameter_dependencies c.cl_module monos;
 			let finalize_field c cf2 =
 				ignore(follow cf.cf_type);
 				let rec check e = match e.eexpr with
@@ -433,6 +432,7 @@ let type_generic_function ctx fa fcc with_type p =
 			if stat then begin
 				if Meta.has Meta.GenericClassPerMethod c.cl_meta then begin
 					let c = static_method_container gctx c cf p in
+					set_type_parameter_dependencies c.cl_module monos;
 					let cf2 = try
 						let cf2 = PMap.find cf.cf_name c.cl_statics in
 						unify_existing_field cf2.cf_type cf2.cf_pos;
@@ -446,6 +446,7 @@ let type_generic_function ctx fa fcc with_type p =
 					in
 					{fa with fa_host = FHStatic c;fa_field = cf2;fa_on = Builder.make_static_this c p}
 				end else begin
+					set_type_parameter_dependencies c.cl_module monos;
 					let cf2 = mk_cf2 name in
 					c.cl_statics <- PMap.add cf2.cf_name cf2 c.cl_statics;
 					c.cl_ordered_statics <- cf2 :: c.cl_ordered_statics;

+ 18 - 0
tests/server/src/cases/display/issues/Issue10635.hx

@@ -18,4 +18,22 @@ class Issue10635 extends DisplayTestCase {
 		runHaxe(args);
 		Assert.isTrue(lastResult.stderr.length == 2); // dumb, but we don't have a proper diagnostics structure in these tests
 	}
+
+	/**
+		class C {
+			public function new() {}
+		}
+
+		function main() {
+			Something.append([new C()], [new C()]);
+		}
+	**/
+	function testGenericClassPerMethod(_) {
+		var args = ["-main", "Main", "--display", "Main.hx@0@diagnostics"];
+		vfs.putContent("Something.hx", "@:genericClassPerMethod " + getTemplate("issues/Issue10635/Something.hx"));
+		runHaxe(args);
+		runHaxeJson([], ServerMethods.Invalidate, {file: new FsPath("Main.hx")});
+		runHaxe(args);
+		Assert.isTrue(lastResult.stderr.length == 2); // dumb, but we don't have a proper diagnostics structure in these tests
+	}
 }