Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro defined modules vs direct loading of types using it #11740

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ let do_type ctx mctx actx display_file_dot_path =
com.callbacks#run com.error_ext com.callbacks#get_after_init_macros;
run_or_diagnose ctx (fun () ->
if com.display.dms_kind <> DMNone then DisplayTexpr.check_display_file tctx cs;
List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes);
List.iter (fun cpath ->
ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos);
Typecore.flush_pass tctx.g (PBuildClass:Typecore.typer_pass) "actx.classes"
) (List.rev actx.classes);
Finalization.finalize tctx;
);
end with TypeloadParse.DisplayInMacroBlock ->
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue11004/build.hxml.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Bar.hx:27: @:storedTypedExpr 3 computed this_ident as: foo.bar
Bar.hx:27: @:storedTypedExpr 1 computed this_ident as: foo.bar
6 changes: 6 additions & 0 deletions tests/misc/projects/Issue11740/Baz.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import foo.Foo;

class Baz {
function baz(data:foo.FooData) {}
}

17 changes: 17 additions & 0 deletions tests/misc/projects/Issue11740/Macro.macro.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import haxe.macro.Context;

class Macro {
public static function build() {
trace("build FooData");

Context.defineType({
pos : Context.currentPos(),
name : "FooData",
pack : ["foo"],
kind : TDClass(),
fields : [],
});

return null;
}
}
5 changes: 5 additions & 0 deletions tests/misc/projects/Issue11740/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import foo.Foo;

function main() {
trace(Baz);
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11740/compile1.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-main Main
--interp
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11740/compile1.hxml.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Macro.macro.hx:5: build FooData
Main.hx:4: Class<Baz>
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11740/compile2.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-main Main
Baz
--interp
4 changes: 4 additions & 0 deletions tests/misc/projects/Issue11740/foo/Foo.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package foo;

@:build(Macro.build())
class Foo {}
Loading