@@ -307,7 +307,6 @@ class AnalyzerContext:
307
307
"_filename" ,
308
308
"_func_ctx" ,
309
309
"_is_quoted" ,
310
- "_macro_ns" ,
311
310
"_opts" ,
312
311
"_recur_points" ,
313
312
"_should_macroexpand" ,
@@ -326,7 +325,6 @@ def __init__(
326
325
self ._filename = Maybe (filename ).or_else_get (DEFAULT_COMPILER_FILE_PATH )
327
326
self ._func_ctx : Deque [FunctionContext ] = collections .deque ([])
328
327
self ._is_quoted : Deque [bool ] = collections .deque ([])
329
- self ._macro_ns : Deque [Optional [runtime .Namespace ]] = collections .deque ([])
330
328
self ._opts = (
331
329
Maybe (opts ).map (lmap .map ).or_else_get (lmap .PersistentMap .empty ()) # type: ignore
332
330
)
@@ -383,35 +381,6 @@ def quoted(self):
383
381
yield
384
382
self ._is_quoted .pop ()
385
383
386
- @property
387
- def current_macro_ns (self ) -> Optional [runtime .Namespace ]:
388
- """Return the current transient namespace available during macroexpansion.
389
-
390
- If None, the analyzer should only use the current namespace for symbol
391
- resolution."""
392
- try :
393
- return self ._macro_ns [- 1 ]
394
- except IndexError :
395
- return None
396
-
397
- @contextlib .contextmanager
398
- def macro_ns (self , ns : Optional [runtime .Namespace ]):
399
- """Set the transient namespace which is available to the analyzer during a
400
- macroexpansion phase.
401
-
402
- If set to None, prohibit the analyzer from using another namespace for symbol
403
- resolution.
404
-
405
- During macroexpansion, new forms referenced from the macro namespace would
406
- be unavailable to the namespace containing the original macro invocation.
407
- The macro namespace is a temporary override pointing to the namespace of the
408
- macro definition which can be used to resolve these transient references."""
409
- self ._macro_ns .append (ns )
410
- try :
411
- yield
412
- finally :
413
- self ._macro_ns .pop ()
414
-
415
384
@property
416
385
def should_allow_unresolved_symbols (self ) -> bool :
417
386
"""If True, the analyzer will allow unresolved symbols. This is primarily
@@ -2285,9 +2254,7 @@ def _invoke_ast(form: Union[llist.PersistentList, ISeq], ctx: AnalyzerContext) -
2285
2254
expanded = expanded .with_meta (
2286
2255
old_meta .cons (form .meta ) if old_meta else form .meta
2287
2256
)
2288
- with ctx .macro_ns (
2289
- fn .var .ns if fn .var .ns is not ctx .current_ns else None
2290
- ), ctx .expr_pos ():
2257
+ with ctx .expr_pos ():
2291
2258
expanded_ast = _analyze_form (expanded , ctx )
2292
2259
2293
2260
# Verify that macroexpanded code also does not have any
@@ -3117,15 +3084,7 @@ def __resolve_namespaced_symbol( # pylint: disable=too-many-branches # noqa: M
3117
3084
v = Var .find (form )
3118
3085
if v is not None :
3119
3086
# Disallow global references to Vars defined with :private metadata
3120
- #
3121
- # Global references to private Vars are allowed in macroexpanded code
3122
- # as long as the macro referencing the private Var is in the same
3123
- # Namespace as the private Var (via `ctx.current_macro_ns`)
3124
- if (
3125
- v .ns != ctx .current_macro_ns
3126
- and v .meta is not None
3127
- and v .meta .val_at (SYM_PRIVATE_META_KEY , False )
3128
- ):
3087
+ if v .meta is not None and v .meta .val_at (SYM_PRIVATE_META_KEY , False ):
3129
3088
raise AnalyzerException (
3130
3089
f"cannot resolve private Var { form .name } from namespace { form .ns } " ,
3131
3090
form = form ,
@@ -3219,16 +3178,6 @@ def __resolve_bare_symbol(
3219
3178
env = ctx .get_node_env (pos = ctx .syntax_position ),
3220
3179
)
3221
3180
3222
- # Look up the symbol in the current macro namespace, if one
3223
- if ctx .current_macro_ns is not None :
3224
- v = ctx .current_macro_ns .find (form )
3225
- if v is not None :
3226
- return VarRef (
3227
- form = form ,
3228
- var = v ,
3229
- env = ctx .get_node_env (pos = ctx .syntax_position ),
3230
- )
3231
-
3232
3181
if "." in form .name :
3233
3182
raise AnalyzerException (
3234
3183
"symbol names may not contain the '.' operator" , form = form
0 commit comments