mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
34 lines
602 B
D
34 lines
602 B
D
@safe pure:
|
|
|
|
class X
|
|
{
|
|
this(int x) @safe pure { this.x = x; }
|
|
int x;
|
|
}
|
|
|
|
class Y : X
|
|
{
|
|
this(int x) @safe pure { super(x); }
|
|
int x;
|
|
}
|
|
|
|
static void fm(X[] xs) {}
|
|
static void fc(const(X)[] xs) {}
|
|
static void fi(immutable(X)[] xs) {}
|
|
|
|
static void f2m(X[2] xs) {}
|
|
static void f2mr(ref X[2] xs) {}
|
|
|
|
void test()
|
|
{
|
|
Y[] y = [new Y(42), new Y(43)];
|
|
immutable(Y)[] yi = [new Y(42), new Y(43)];
|
|
static assert(!__traits(compiles, { fm(y); }));
|
|
fc(y);
|
|
fc(yi);
|
|
fi(yi);
|
|
|
|
Y[2] y2 = [new Y(42), new Y(43)];
|
|
f2m(y2);
|
|
static assert(!__traits(compiles, { f2mr(y2); }));
|
|
}
|