From 39a33605f1ea7dc4137a4765e9a89c90fa55745f Mon Sep 17 00:00:00 2001 From: mentegy Date: Tue, 22 May 2018 14:26:25 +0300 Subject: [PATCH] Add note of separate compilation unit in macro's code example --- docs/docs/reference/principled-meta-programming.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/docs/reference/principled-meta-programming.md b/docs/docs/reference/principled-meta-programming.md index 76d493b5e46d..a3b972618e97 100644 --- a/docs/docs/reference/principled-meta-programming.md +++ b/docs/docs/reference/principled-meta-programming.md @@ -322,9 +322,12 @@ program that calls `assert`. '{ if !(~expr) then throw new AssertionError(s"failed assertion: ${~expr}") } } - val program = { - val x = 1 - Macros.assert(x != 0) + // has to be in a different compilation unit that depends on Macros + object App { + val program = { + val x = 1 + Macros.assert(x != 0) + } } Inlining the `assert` function would give the following program: