Skip to content

Commit

Permalink
remove uses of classinfo, rebases part of #7445 (#9063)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator authored Oct 27, 2024
1 parent 08858e0 commit 81ce86e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,22 @@ if (!is(S : T) &&
auto result = ()@trusted{ return cast(T) value; }();
if (!result && value)
{
throw new ConvException("Cannot convert object of static type "
~S.classinfo.name~" and dynamic type "~value.classinfo.name
~" to type "~T.classinfo.name);
string name(TypeInfo ti) @trusted
{
while (auto tc = (cast(TypeInfo_Const) ti))
{
ti = tc.base;
}
if (auto tinf = (cast(TypeInfo_Interface) ti))
{
ti = tinf.info;
}
TypeInfo_Class tc = cast(TypeInfo_Class) ti;
assert(tc);
return tc.name;
}
throw new ConvException("Cannot convert object of static type " ~
name(typeid(S)) ~ " and dynamic type " ~ name(typeid(value)) ~ " to type " ~ name(typeid(T)));
}
return result;
}
Expand Down

0 comments on commit 81ce86e

Please sign in to comment.