Skip to content

Commit 81ce86e

Browse files
remove uses of classinfo, rebases part of #7445 (#9063)
1 parent 08858e0 commit 81ce86e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

std/conv.d

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,22 @@ if (!is(S : T) &&
917917
auto result = ()@trusted{ return cast(T) value; }();
918918
if (!result && value)
919919
{
920-
throw new ConvException("Cannot convert object of static type "
921-
~S.classinfo.name~" and dynamic type "~value.classinfo.name
922-
~" to type "~T.classinfo.name);
920+
string name(TypeInfo ti) @trusted
921+
{
922+
while (auto tc = (cast(TypeInfo_Const) ti))
923+
{
924+
ti = tc.base;
925+
}
926+
if (auto tinf = (cast(TypeInfo_Interface) ti))
927+
{
928+
ti = tinf.info;
929+
}
930+
TypeInfo_Class tc = cast(TypeInfo_Class) ti;
931+
assert(tc);
932+
return tc.name;
933+
}
934+
throw new ConvException("Cannot convert object of static type " ~
935+
name(typeid(S)) ~ " and dynamic type " ~ name(typeid(value)) ~ " to type " ~ name(typeid(T)));
923936
}
924937
return result;
925938
}

0 commit comments

Comments
 (0)