@@ -5073,7 +5073,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
5073
5073
if (!subscripts.isNull ()) {
5074
5074
// If we have a value and index list, create a new rvalue to represent the
5075
5075
// both of them together.
5076
- auto inputTupleType = cast <TupleType>(accessType.getInput ());
5076
+ auto inputTupleType = dyn_cast <TupleType>(accessType.getInput ());
5077
5077
5078
5078
SmallVector<ArgumentSource, 4 > eltSources;
5079
5079
@@ -5086,18 +5086,25 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
5086
5086
// TODO: we should really take an array of RValues.
5087
5087
if (accessType->getNumParams () != 2 ) {
5088
5088
auto subscriptsTupleType = cast<TupleType>(subscripts.getType ());
5089
- assert (inputTupleType-> getNumElements ()
5089
+ assert (accessType. getParams (). size ()
5090
5090
== 1 + subscriptsTupleType->getNumElements ());
5091
5091
SmallVector<RValue, 8 > eltRVs;
5092
5092
std::move (subscripts).extractElements (eltRVs);
5093
5093
for (auto &elt : eltRVs)
5094
5094
eltSources.emplace_back (loc, std::move (elt));
5095
5095
} else {
5096
+ assert (inputTupleType && " Must have an input tuple here" );
5096
5097
subscripts.rewriteType (inputTupleType.getElementType (1 ));
5097
5098
eltSources.emplace_back (loc, std::move (subscripts));
5098
5099
}
5099
5100
5100
- setValue = ArgumentSource (loc, inputTupleType, eltSources);
5101
+ if (inputTupleType) {
5102
+ setValue = ArgumentSource (loc, inputTupleType, eltSources);
5103
+ } else {
5104
+ assert (eltSources.size () == 1 );
5105
+ setValue = std::move (eltSources.front ());
5106
+ }
5107
+
5101
5108
} else {
5102
5109
setValue.rewriteType (accessType.getInput ());
5103
5110
}
0 commit comments