Changes in / [18d7aaf:ce0b8b8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r18d7aaf rce0b8b8 522 522 CandidateFinder subFinder( context, env ); 523 523 expr = subFinder.makeEnumOffsetCast(argAsEnum, paramAsEnum, expr, c); 524 if ( expr ) 525 results.emplace_back( 526 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), 527 nextArg + 1, nTuples, expl.cost + c, expl.exprs.size() == 1 ? 0 : 1, j ); 524 results.emplace_back( 525 i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ), 526 nextArg + 1, nTuples, expl.cost + c, expl.exprs.size() == 1 ? 0 : 1, j ); 528 527 continue; 529 528 } else { … … 1266 1265 CandidateFinder subFinder(context, tenv); 1267 1266 ast::ptr<ast::Expr> offsetExpr = subFinder.makeEnumOffsetCast(argAsEnum, toAsEnum, cand->expr, thisCost); 1268 if ( offsetExpr ) 1269 cand->expr = offsetExpr; 1267 cand->expr = offsetExpr; 1270 1268 } 1271 1269 … … 2153 2151 2154 2152 const ast::Expr * CandidateFinder::makeEnumOffsetCast( const ast::EnumInstType * src, 2155 const ast::EnumInstType * dst, const ast::Expr * expr, Cost minCost ) { 2153 const ast::EnumInstType * dst, 2154 const ast::Expr * expr, 2155 Cost minCost ) { 2156 2156 2157 auto srcDecl = src->base; 2157 2158 auto dstDecl = dst->base; … … 2178 2179 CandidateRef & choice = winners.front(); 2179 2180 choice->expr = new ast::CastExpr(expr->location, choice->expr, dstChild, ast::GeneratedFlag::ExplicitCast); 2180 auto destExpr = makeEnumOffsetCast( src, dstChild, choice->expr, minCost );2181 if ( !destExpr ) continue;2182 castToDst = new ast::CastExpr( destExpr, dst);2181 castToDst = new ast::CastExpr( 2182 makeEnumOffsetCast( src, dstChild, choice->expr, minCost ), 2183 dst); 2183 2184 } else { 2184 2185 castToDst = new ast::CastExpr( expr, dst ); … … 2187 2188 } 2188 2189 } 2190 SemanticError(expr, src->base->name + " is not a subtype of " + dst->base->name); 2189 2191 return nullptr; 2190 2192 }
Note: See TracChangeset
for help on using the changeset viewer.