Skip to content

Commit ff50a1b

Browse files
Workaround for TypeInfo bug in LDC 1.42 ldc-developers/ldc#5034
1 parent 28cfc6d commit ff50a1b

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

source/numem/core/lifetime.d

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,19 @@ void destruct(T, bool reInit=true)(ref T obj_) @nogc {
105105
if (obj_ !is null) {
106106
static if (hasAnyDestructor!RealT) {
107107
static if (__traits(getLinkage, RealT) == "D") {
108-
auto cInfo = cast(ClassInfo)typeid(obj_);
109-
if (cInfo) {
110-
auto c = cInfo;
111-
112-
// Call destructors in order of most specific
113-
// to least-specific
114-
do {
115-
if (c.destructor)
116-
(cast(fp_t)c.destructor)(cast(Object)obj_);
117-
} while((c = c.base) !is null);
118-
108+
static if (is(RealT == class)) {
109+
auto cInfo = cast(TypeInfo_Class)typeid(obj_);
110+
if (cInfo) {
111+
auto c = cInfo;
112+
113+
// Call destructors in order of most specific
114+
// to least-specific
115+
do {
116+
if (c.destructor)
117+
(cast(fp_t)c.destructor)(cast(Object)obj_);
118+
} while((c = c.base) !is null);
119+
120+
}
119121
} else {
120122

121123
// Item is a struct, we can destruct it directly.

0 commit comments

Comments
 (0)