diff --git a/src/typing/typeloadFields.ml b/src/typing/typeloadFields.ml index d70d066600a..bd772db552f 100644 --- a/src/typing/typeloadFields.ml +++ b/src/typing/typeloadFields.ml @@ -753,13 +753,21 @@ module TypeBinding = struct | TMono r -> (match r.tm_type with None -> false | Some t -> is_full_type t) | TAbstract _ | TInst _ | TEnum _ | TLazy _ | TDynamic _ | TAnon _ | TType _ -> true in - let force_macro () = + let force_macro display = (* force macro system loading of this class in order to get completion *) - delay ctx PTypeField (fun() -> try ignore(ctx.g.do_macro ctx MDisplay c.cl_path cf.cf_name [] p) with Exit | Error _ -> ()) + delay ctx PTypeField (fun() -> + try + ignore(ctx.g.do_macro ctx MDisplay c.cl_path cf.cf_name [] p) + with + | Exit -> + () + | Error _ when display -> + () + ) in let handle_display_field () = if fctx.is_macro && not ctx.in_macro then - force_macro() + force_macro true else begin cf.cf_type <- TLazy r; cctx.delayed_expr <- (ctx,Some r) :: cctx.delayed_expr; @@ -767,14 +775,14 @@ module TypeBinding = struct in if ctx.com.display.dms_full_typing then begin if fctx.is_macro && not ctx.in_macro then - force_macro () + force_macro false else begin cf.cf_type <- TLazy r; (* is_lib ? *) cctx.delayed_expr <- (ctx,Some r) :: cctx.delayed_expr; end end else if ctx.com.display.dms_force_macro_typing && fctx.is_macro && not ctx.in_macro then - force_macro() + force_macro true else begin if fctx.is_display_field then begin handle_display_field() diff --git a/tests/misc/projects/Issue10587/Macro.hx b/tests/misc/projects/Issue10587/Macro.hx new file mode 100644 index 00000000000..e30554a89ee --- /dev/null +++ b/tests/misc/projects/Issue10587/Macro.hx @@ -0,0 +1,3 @@ +class Macro { + public static macro function foo(e:Expr) {} +} \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/MainImport.hx b/tests/misc/projects/Issue10587/MainImport.hx new file mode 100644 index 00000000000..55eb4b3892b --- /dev/null +++ b/tests/misc/projects/Issue10587/MainImport.hx @@ -0,0 +1,7 @@ +import Macro; + +class Main { + static function main() { + Macro.foo( 1 ); + } +} \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/MainUsing.hx b/tests/misc/projects/Issue10587/MainUsing.hx new file mode 100644 index 00000000000..e739782aaf3 --- /dev/null +++ b/tests/misc/projects/Issue10587/MainUsing.hx @@ -0,0 +1,7 @@ +using Macro; + +class Main { + static function main() { + 1.foo(); + } +} \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/compile-import-fail.hxml b/tests/misc/projects/Issue10587/compile-import-fail.hxml new file mode 100644 index 00000000000..0ce6c407c12 --- /dev/null +++ b/tests/misc/projects/Issue10587/compile-import-fail.hxml @@ -0,0 +1,2 @@ +--main MainImport +--interp \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/compile-import-fail.hxml.stderr b/tests/misc/projects/Issue10587/compile-import-fail.hxml.stderr new file mode 100644 index 00000000000..9506f0648df --- /dev/null +++ b/tests/misc/projects/Issue10587/compile-import-fail.hxml.stderr @@ -0,0 +1 @@ +Macro.hx:2: characters 37-41 : Type not found : Expr \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/compile-using-fail.hxml b/tests/misc/projects/Issue10587/compile-using-fail.hxml new file mode 100644 index 00000000000..d2a71e00c26 --- /dev/null +++ b/tests/misc/projects/Issue10587/compile-using-fail.hxml @@ -0,0 +1,2 @@ +--main MainUsing +--interp \ No newline at end of file diff --git a/tests/misc/projects/Issue10587/compile-using-fail.hxml.stderr b/tests/misc/projects/Issue10587/compile-using-fail.hxml.stderr new file mode 100644 index 00000000000..9506f0648df --- /dev/null +++ b/tests/misc/projects/Issue10587/compile-using-fail.hxml.stderr @@ -0,0 +1 @@ +Macro.hx:2: characters 37-41 : Type not found : Expr \ No newline at end of file