mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 13:40:11 +03:00
Fix #20603.
hasIndirections does not take enums into account, whereas if an enum's base type has indirections, then clearly, the enum type does as well.
This commit is contained in:
parent
c55343c71d
commit
b2c83e9921
1 changed files with 55 additions and 1 deletions
|
@ -538,7 +538,9 @@ unittest
|
||||||
|
|
||||||
template hasIndirections(T)
|
template hasIndirections(T)
|
||||||
{
|
{
|
||||||
static if (is(T == struct) || is(T == union))
|
static if (is(T == enum))
|
||||||
|
enum hasIndirections = hasIndirections!(OriginalType!T);
|
||||||
|
else static if (is(T == struct) || is(T == union))
|
||||||
enum hasIndirections = anySatisfy!(.hasIndirections, typeof(T.tupleof));
|
enum hasIndirections = anySatisfy!(.hasIndirections, typeof(T.tupleof));
|
||||||
else static if (__traits(isAssociativeArray, T) || is(T == class) || is(T == interface))
|
else static if (__traits(isAssociativeArray, T) || is(T == class) || is(T == interface))
|
||||||
enum hasIndirections = true;
|
enum hasIndirections = true;
|
||||||
|
@ -595,26 +597,78 @@ template hasIndirections(T)
|
||||||
static interface I {}
|
static interface I {}
|
||||||
static assert( hasIndirections!I);
|
static assert( hasIndirections!I);
|
||||||
|
|
||||||
|
{
|
||||||
|
enum E : int { a }
|
||||||
|
static assert(!hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : int* { a }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : string { a = "" }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : int[] { a = null }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : int[3] { a = [1, 2, 3] }
|
||||||
|
static assert(!hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : int*[3] { a = [null, null, null] }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : int*[0] { a = int*[0].init }
|
||||||
|
static assert(!hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : C { a = null }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
enum E : I { a = null }
|
||||||
|
static assert( hasIndirections!E);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
static struct S {}
|
static struct S {}
|
||||||
static assert(!hasIndirections!S);
|
static assert(!hasIndirections!S);
|
||||||
|
|
||||||
|
enum E : S { a = S.init }
|
||||||
|
static assert(!hasIndirections!S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
static struct S { int i; }
|
static struct S { int i; }
|
||||||
static assert(!hasIndirections!S);
|
static assert(!hasIndirections!S);
|
||||||
|
|
||||||
|
enum E : S { a = S.init }
|
||||||
|
static assert(!hasIndirections!S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
static struct S { C c; }
|
static struct S { C c; }
|
||||||
static assert( hasIndirections!S);
|
static assert( hasIndirections!S);
|
||||||
|
|
||||||
|
enum E : S { a = S.init }
|
||||||
|
static assert( hasIndirections!S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
static struct S { int[] arr; }
|
static struct S { int[] arr; }
|
||||||
static assert( hasIndirections!S);
|
static assert( hasIndirections!S);
|
||||||
|
|
||||||
|
enum E : S { a = S.init }
|
||||||
|
static assert( hasIndirections!S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int local;
|
int local;
|
||||||
struct S { void foo() { ++local; } }
|
struct S { void foo() { ++local; } }
|
||||||
static assert( hasIndirections!S);
|
static assert( hasIndirections!S);
|
||||||
|
|
||||||
|
enum E : S { a = S.init }
|
||||||
|
static assert( hasIndirections!S);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue