diff --git a/compiler/src/dmd/mtype.d b/compiler/src/dmd/mtype.d index 0f4f91d8473f..0e961e9afa87 100644 --- a/compiler/src/dmd/mtype.d +++ b/compiler/src/dmd/mtype.d @@ -4558,6 +4558,46 @@ extern (C++) final class TypeTuple : Type { v.visit(this); } + + override final Type makeConst() + { + if (mcache && mcache.cto) + { + assert(mcache.cto.isConst()); + return mcache.cto; + } + TypeTuple t = cast(TypeTuple) Type.makeConst(); + if (arguments) + { + t.arguments = new Parameters(arguments.length); + foreach (i, ref arg; *t.arguments) + { + auto tsrc = (*arguments)[i].type; + arg = new Parameter(Loc.initial, 0, tsrc.addSTC(STC.const_), null, null, null); + } + } + return t; + } + + override final Type makeImmutable() + { + if (mcache && mcache.ito) + { + assert(mcache.ito.isImmutable()); + return mcache.ito; + } + TypeTuple t = cast(TypeTuple) Type.makeImmutable(); + if (arguments) + { + t.arguments = new Parameters(arguments.length); + foreach (i, ref arg; *t.arguments) + { + auto tsrc = (*arguments)[i].type; + arg = new Parameter(Loc.initial, 0, tsrc.immutableOf(), null, null, null); + } + } + return t; + } } /*********************************************************** diff --git a/compiler/test/compilable/type_seq_qual.d b/compiler/test/compilable/type_seq_qual.d new file mode 100644 index 000000000000..8e6bfe4487a0 --- /dev/null +++ b/compiler/test/compilable/type_seq_qual.d @@ -0,0 +1,16 @@ +alias AliasSeq(Args...) = Args; + +immutable(AliasSeq!(int, float)) c; +immutable AliasSeq!(int, float) d; +static assert(is(typeof(c) == typeof(d))); + +alias TS = AliasSeq!(int, float); +static assert(is(typeof(c) == immutable TS)); +static assert(is(immutable(TS)[0] == immutable int)); + +static assert(is(const(TS) == const TS)); +static assert(is(const(AliasSeq!(int, float))[0] == const int)); // OK +static assert(is(const(TS)[0] == const int)); // fails + +alias CT = const(TS); +static assert(is(CT[0] == const int));