@@ -392,6 +392,7 @@ static class DefExpr implements Expr{
392
392
public final Expr meta ;
393
393
public final boolean initProvided ;
394
394
public final boolean isDynamic ;
395
+ public final boolean shadowsCoreMapping ;
395
396
public final String source ;
396
397
public final int line ;
397
398
public final int column ;
@@ -400,15 +401,17 @@ static class DefExpr implements Expr{
400
401
final static Method setMetaMethod = Method .getMethod ("void setMeta(clojure.lang.IPersistentMap)" );
401
402
final static Method setDynamicMethod = Method .getMethod ("clojure.lang.Var setDynamic(boolean)" );
402
403
final static Method symintern = Method .getMethod ("clojure.lang.Symbol intern(String, String)" );
404
+ final static Method internVar = Method .getMethod ("clojure.lang.Var refer(clojure.lang.Symbol, clojure.lang.Var)" );
403
405
404
- public DefExpr (String source , int line , int column , Var var , Expr init , Expr meta , boolean initProvided , boolean isDynamic ){
406
+ public DefExpr (String source , int line , int column , Var var , Expr init , Expr meta , boolean initProvided , boolean isDynamic , boolean shadowsCoreMapping ){
405
407
this .source = source ;
406
408
this .line = line ;
407
409
this .column = column ;
408
410
this .var = var ;
409
411
this .init = init ;
410
412
this .meta = meta ;
411
413
this .isDynamic = isDynamic ;
414
+ this .shadowsCoreMapping = shadowsCoreMapping ;
412
415
this .initProvided = initProvided ;
413
416
}
414
417
@@ -454,6 +457,18 @@ public Object eval() {
454
457
455
458
public void emit (C context , ObjExpr objx , GeneratorAdapter gen ){
456
459
objx .emitVar (gen , var );
460
+
461
+ if (shadowsCoreMapping )
462
+ {
463
+ gen .dup ();
464
+ gen .getField (VAR_TYPE , "ns" , NS_TYPE );
465
+ gen .swap ();
466
+ gen .dup ();
467
+ gen .getField (VAR_TYPE , "sym" , SYMBOL_TYPE );
468
+ gen .swap ();
469
+ gen .invokeVirtual (NS_TYPE , internVar );
470
+ }
471
+
457
472
if (isDynamic )
458
473
{
459
474
gen .push (isDynamic );
@@ -511,11 +526,13 @@ else if(!(RT.second(form) instanceof Symbol))
511
526
Var v = lookupVar (sym , true );
512
527
if (v == null )
513
528
throw Util .runtimeException ("Can't refer to qualified var that doesn't exist" );
529
+ boolean shadowsCoreMapping = false ;
514
530
if (!v .ns .equals (currentNS ()))
515
531
{
516
532
if (sym .ns == null )
517
533
{
518
534
v = currentNS ().intern (sym );
535
+ shadowsCoreMapping = true ;
519
536
registerVar (v );
520
537
}
521
538
// throw Util.runtimeException("Name conflict, can't def " + sym + " because namespace: " + currentNS().name +
@@ -559,7 +576,7 @@ else if(!(RT.second(form) instanceof Symbol))
559
576
Expr meta = mm .count ()==0 ? null :analyze (context == C .EVAL ? context : C .EXPRESSION , mm );
560
577
return new DefExpr ((String ) SOURCE .deref (), lineDeref (), columnDeref (),
561
578
v , analyze (context == C .EVAL ? context : C .EXPRESSION , RT .third (form ), v .sym .name ),
562
- meta , RT .count (form ) == 3 , isDynamic );
579
+ meta , RT .count (form ) == 3 , isDynamic , shadowsCoreMapping );
563
580
}
564
581
}
565
582
}
0 commit comments