mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
Fix issue 1024: allow classes to be cast to typeof(null)
... and always return null in that case.
This commit is contained in:
parent
532353f5a2
commit
5d71dc38df
1 changed files with 5 additions and 0 deletions
|
@ -236,6 +236,11 @@ DValue* DtoCastClass(Loc& loc, DValue* val, Type* _to)
|
||||||
DImValue im(Type::tsize_t, v);
|
DImValue im(Type::tsize_t, v);
|
||||||
return DtoCastInt(loc, &im, _to);
|
return DtoCastInt(loc, &im, _to);
|
||||||
}
|
}
|
||||||
|
// class -> typeof(null)
|
||||||
|
else if (to->ty == Tnull) {
|
||||||
|
IF_LOG Logger::println("to %s", to->toChars());
|
||||||
|
return new DImValue(_to, LLConstant::getNullValue(DtoType(_to)));
|
||||||
|
}
|
||||||
|
|
||||||
// must be class/interface
|
// must be class/interface
|
||||||
assert(to->ty == Tclass);
|
assert(to->ty == Tclass);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue