SILGen: When transforming to AnyHashable materialize the value in a temporary

emitAnyHashable expects an address value.

rdar://40583597
This commit is contained in:
Arnold Schwaighofer
2018-07-12 15:00:10 -07:00
parent 56f322f6f5
commit a3fd504025
2 changed files with 22 additions and 2 deletions

View File

@@ -598,8 +598,10 @@ ManagedValue Transform::transform(ManagedValue v,
KnownProtocolKind::Hashable);
auto conformance = SGF.SGM.M.getSwiftModule()->lookupConformance(
inputSubstType, protocol);
auto result = SGF.emitAnyHashableErasure(Loc, v, inputSubstType,
*conformance, ctxt);
auto addr = v.getType().isAddress() ? v : v.materialize(SGF, Loc);
auto result = SGF.emitAnyHashableErasure(Loc, addr,
inputSubstType, *conformance,
ctxt);
if (result.isInContext())
return ManagedValue::forInContext();
return std::move(result).getAsSingleValue(SGF, Loc);