Skip to content

Commit f8c46ce

Browse files
committed
Type.fixTo: Always propagate the naked type to new variants
1 parent 662104f commit f8c46ce

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

compiler/src/dmd/typesem.d

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,17 @@ 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.
471471
Type mto = null;
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)
@@ -479,42 +484,42 @@ void fixTo(Type _this, Type t)
479484
break;
480485

481486
case MODFlags.const_:
482-
_this.getMcache();
487+
mto = t.mcache.cto;
483488
_this.mcache.cto = t;
484489
break;
485490

486491
case MODFlags.wild:
487-
_this.getMcache();
492+
mto = t.mcache.wto;
488493
_this.mcache.wto = t;
489494
break;
490495

491496
case MODFlags.wildconst:
492-
_this.getMcache();
497+
mto = t.mcache.wcto;
493498
_this.mcache.wcto = t;
494499
break;
495500

496501
case MODFlags.shared_:
497-
_this.getMcache();
502+
mto = t.mcache.sto;
498503
_this.mcache.sto = t;
499504
break;
500505

501506
case MODFlags.shared_ | MODFlags.const_:
502-
_this.getMcache();
507+
mto = t.mcache.scto;
503508
_this.mcache.scto = t;
504509
break;
505510

506511
case MODFlags.shared_ | MODFlags.wild:
507-
_this.getMcache();
512+
mto = t.mcache.swto;
508513
_this.mcache.swto = t;
509514
break;
510515

511516
case MODFlags.shared_ | MODFlags.wildconst:
512-
_this.getMcache();
517+
mto = t.mcache.swcto;
513518
_this.mcache.swcto = t;
514519
break;
515520

516521
case MODFlags.immutable_:
517-
_this.getMcache();
522+
mto = t.mcache.ito;
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:

0 commit comments

Comments
 (0)