| 1 |
|
| 2 |
// https://issues.dlang.org/show_bug.cgi?id=3543 |
| 3 |
|
| 4 |
// merge with commontype.d? |
| 5 |
|
| 6 |
void testi(bool bla) |
| 7 |
{ |
| 8 |
interface Root { } |
| 9 |
interface A : Root { } |
| 10 |
interface B : Root { } |
| 11 |
A a; |
| 12 |
B b; |
| 13 |
Root r = bla ? a : b; |
| 14 |
static assert(is(typeof(r) == Root)); |
| 15 |
Root[] t = [a, b]; |
| 16 |
static assert(is(typeof(t[0]) == Root)); |
| 17 |
} |
| 18 |
|
| 19 |
void testc(bool bla) |
| 20 |
{ |
| 21 |
class Root { } |
| 22 |
class A : Root { } |
| 23 |
class B : Root { } |
| 24 |
A a; |
| 25 |
B b; |
| 26 |
Root r = bla ? a : b; |
| 27 |
static assert(is(typeof(r) == Root)); |
| 28 |
Root[] t = [a, b]; |
| 29 |
static assert(is(typeof(t[0]) == Root)); |
| 30 |
} |
| 31 |
|
| 32 |
void teste(bool bla) |
| 33 |
{ |
| 34 |
interface Root { } |
| 35 |
interface Othe { } |
| 36 |
interface A : Root, Othe { } |
| 37 |
interface B : Root, Othe { } |
| 38 |
A a; |
| 39 |
B b; |
| 40 |
static assert(!__traits(compiles, bla ? a : b)); |
| 41 |
} |
| 42 |
|
| 43 |
void testf(bool bla) |
| 44 |
{ |
| 45 |
interface Othe { } |
| 46 |
interface Root : Othe { } |
| 47 |
interface A : Root { } |
| 48 |
interface B : Othe { } |
| 49 |
A a; |
| 50 |
B b; |
| 51 |
Othe r = bla ? a : b; |
| 52 |
} |
| 53 |
|
| 54 |
void testg() |
| 55 |
{ |
| 56 |
interface A{} |
| 57 |
interface B{} |
| 58 |
|
| 59 |
interface C:A{} |
| 60 |
interface D:B,C{} |
| 61 |
|
| 62 |
interface E:B{} |
| 63 |
interface F:A,E{} |
| 64 |
|
| 65 |
D d; |
| 66 |
F f; |
| 67 |
static assert(!__traits(compiles, true ? d : f)); |
| 68 |
static assert(!__traits(compiles, true ? f : d)); |
| 69 |
} |
| 70 |
|
| 71 |
void testh() |
| 72 |
{ |
| 73 |
interface I {} |
| 74 |
class B {} |
| 75 |
class C : B, I {} |
| 76 |
class D : B {} |
| 77 |
C c; |
| 78 |
D d; |
| 79 |
auto b = true ? c : d; |
| 80 |
} |