@@ -464,57 +464,62 @@ void check(Type _this)
464464 * For our new type '_this', which is type-constructed from t,
465465 * fill in the cto, ito, sto, scto, wto shortcuts.
466466 */
467- void fixTo (Type _this, Type t)
467+ private void fixTo (Type _this, Type t)
468468{
469469 // If fixing this: immutable(T*) by t: immutable(T)*,
470470 // cache t to this.xto won't break transitivity.
471- Type mto = null ;
471+ Type mto = null ; // the naked type of `t`
472472 Type tn = _this.nextOf();
473+ if (_this.mod || t.mod)
474+ {
475+ _this.getMcache();
476+ t.getMcache();
477+ }
473478 if (! tn || _this.ty != Tsarray && tn.mod == t.nextOf().mod)
474479 {
475480 switch (t.mod)
476481 {
477482 case 0 :
478- mto = t;
483+ mto = t; // t is naked
479484 break ;
480485
481486 case MODFlags.const_:
482- _this.getMcache();
487+ mto = t.mcache.cto; // cto is naked
483488 _this.mcache.cto = t;
484489 break ;
485490
486491 case MODFlags.wild:
487- _this.getMcache();
492+ mto = t.mcache.wto; // wto is naked
488493 _this.mcache.wto = t;
489494 break ;
490495
491496 case MODFlags.wildconst:
492- _this.getMcache();
497+ mto = t.mcache.wcto; // wcto is naked
493498 _this.mcache.wcto = t;
494499 break ;
495500
496501 case MODFlags.shared_:
497- _this.getMcache();
502+ mto = t.mcache.sto; // sto is naked
498503 _this.mcache.sto = t;
499504 break ;
500505
501506 case MODFlags.shared_ | MODFlags.const_:
502- _this.getMcache();
507+ mto = t.mcache.scto; // scto is naked
503508 _this.mcache.scto = t;
504509 break ;
505510
506511 case MODFlags.shared_ | MODFlags.wild:
507- _this.getMcache();
512+ mto = t.mcache.swto; // swto is naked
508513 _this.mcache.swto = t;
509514 break ;
510515
511516 case MODFlags.shared_ | MODFlags.wildconst:
512- _this.getMcache();
517+ mto = t.mcache.swcto; // swcto is naked
513518 _this.mcache.swcto = t;
514519 break ;
515520
516521 case MODFlags.immutable_:
517- _this.getMcache();
522+ mto = t.mcache.ito; // ito is naked
518523 _this.mcache.ito = t;
519524 break ;
520525
@@ -524,11 +529,6 @@ void fixTo(Type _this, Type t)
524529 }
525530 assert (_this.mod != t.mod);
526531
527- if (_this.mod)
528- {
529- _this.getMcache();
530- t.getMcache();
531- }
532532 switch (_this.mod)
533533 {
534534 case 0 :
@@ -8529,6 +8529,15 @@ Type immutableOf(Type type)
85298529
85308530/* *******************************
85318531 * Make type mutable.
8532+ * 0 => 0
8533+ * const => 0
8534+ * immutable => 0
8535+ * shared => shared
8536+ * shared const => shared
8537+ * wild => 0
8538+ * wild const => 0
8539+ * shared wild => shared
8540+ * shared wild const => shared
85328541 */
85338542Type mutableOf (Type type)
85348543{
@@ -8545,15 +8554,12 @@ Type mutableOf(Type type)
85458554 type.getMcache();
85468555 if (type.isShared())
85478556 {
8548- if (type.isWild())
8549- t = type.mcache.swcto; // shared wild const -> shared
8550- else
8551- t = type.mcache.sto; // shared const => shared
8557+ t = type.mcache.sto; // shared (wild) const => shared
85528558 }
85538559 else
85548560 {
85558561 if (type.isWild())
8556- t = type.mcache.wcto; // wild const - > naked
8562+ t = type.mcache.wcto; // wild const = > naked
85578563 else
85588564 t = type.mcache.cto; // const => naked
85598565 }
0 commit comments