Procházet zdrojové kódy

[typer] delay add_constructor (#12364)

* [typer] delay add_constructor

* [tests] Add test for #12357
Rudy Ges před 20 hodinami
rodič
revize
aa3ecc5502

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1797,5 +1797,5 @@ let init_class ctx_c cctx c p herits fields =
 	end;
 	if not has_struct_init then
 		(* add_constructor does not deal with overloads correctly *)
-		if not com.config.pf_overload then TypeloadFunction.add_constructor ctx_c c cctx.force_constructor p;
+		if not com.config.pf_overload then delay_late ctx_c.g PConnectField (fun() -> TypeloadFunction.add_constructor ctx_c c cctx.force_constructor p);
 	finalize_class cctx

+ 4 - 0
tests/misc/projects/Issue12357/compile-hxb.hxml

@@ -0,0 +1,4 @@
+-cp src
+-main Main
+-hl bin/dummy.hl
+--hxb bin/hxb.zip

+ 5 - 0
tests/misc/projects/Issue12357/compile-with-hxblib.hxml

@@ -0,0 +1,5 @@
+-cp src
+--hxb-lib bin/hxb.zip
+-main Main
+MyException
+-hl bin/dummy.hl

+ 1 - 0
tests/misc/projects/Issue12357/src/Main.hx

@@ -0,0 +1 @@
+function main() {}

+ 1 - 0
tests/misc/projects/Issue12357/src/MyException.hx

@@ -0,0 +1 @@
+class MyException extends haxe.Exception {}