Add cast_intrusive() and make use of it in two spots

This commit is contained in:
Jon Siwek 2020-05-06 17:37:23 -07:00
parent c6f2e35af0
commit 6a1e4d61d1
3 changed files with 18 additions and 6 deletions

View file

@ -2393,8 +2393,7 @@ IntrusivePtr<Val> AssignExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr)
if ( aggr->Type()->Tag() != TYPE_TABLE )
Internal("bad aggregate in AssignExpr::InitVal");
// TODO: implement safer IntrusivePtr casts
IntrusivePtr<TableVal> tv{NewRef{}, aggr->AsTableVal()};
auto tv = cast_intrusive<TableVal>(std::move(aggr));
const TableType* tt = tv->Type()->AsTableType();
const BroType* yt = tv->Type()->YieldType();