@@ -1538,39 +1538,43 @@ static bool isMatchedAnyToAnyObjectConversion(CanType from, CanType to) {
15381538 return false ;
15391539}
15401540
1541- static Conversion withNewInputType (const Conversion &conv,
1542- AbstractionPattern origType,
1543- CanType substType,
1544- SILType loweredType) {
1545- switch (conv.getKind ()) {
1546- case Conversion::Reabstract:
1547- return Conversion::getReabstract (origType, substType, loweredType,
1548- conv.getReabstractionOutputOrigType (),
1549- conv.getReabstractionOutputSubstType (),
1550- conv.getReabstractionOutputLoweredType ());
1551- case Conversion::Subtype:
1552- return Conversion::getSubtype (substType, conv.getBridgingResultType (),
1553- conv.getBridgingLoweredResultType ());
1541+ Conversion
1542+ Conversion::withSourceType (SILGenFunction &SGF, CanType substType) const {
1543+ return withSourceType (AbstractionPattern (substType), substType,
1544+ SGF.getLoweredType (substType));
1545+ }
1546+
1547+ Conversion
1548+ Conversion::withSourceType (AbstractionPattern origType,
1549+ CanType substType, SILType loweredType) const {
1550+ switch (getKind ()) {
1551+ case Reabstract:
1552+ return getReabstract (origType, substType, loweredType,
1553+ getReabstractionOutputOrigType (),
1554+ getReabstractionOutputSubstType (),
1555+ getReabstractionOutputLoweredType ());
1556+ case Subtype:
1557+ return getSubtype (substType, getResultType (), getLoweredResultType ());
15541558 default :
1555- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1559+ llvm_unreachable (" operation not supported on specialized bridging "
1560+ " conversions" );
15561561 }
15571562}
15581563
1559- static Conversion withNewOutputType (const Conversion &conv,
1560- AbstractionPattern origType,
1561- CanType substType,
1562- SILType loweredType) {
1563- switch (conv.getKind ()) {
1564- case Conversion::Reabstract:
1565- return Conversion::getReabstract (conv.getReabstractionInputOrigType (),
1566- conv.getReabstractionInputSubstType (),
1567- conv.getReabstractionInputLoweredType (),
1568- origType, substType, loweredType);
1569- case Conversion::Subtype:
1570- return Conversion::getSubtype (conv.getBridgingSourceType (),
1571- substType, loweredType);
1564+ Conversion
1565+ Conversion::withResultType (AbstractionPattern origType,
1566+ CanType substType, SILType loweredType) const {
1567+ switch (getKind ()) {
1568+ case Reabstract:
1569+ return getReabstract (getReabstractionInputOrigType (),
1570+ getReabstractionInputSubstType (),
1571+ getReabstractionInputLoweredType (),
1572+ origType, substType, loweredType);
1573+ case Subtype:
1574+ return getSubtype (getSourceType (), substType, loweredType);
15721575 default :
1573- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1576+ llvm_unreachable (" operation not supported on specialized bridging "
1577+ " conversions" );
15741578 }
15751579}
15761580
@@ -1735,12 +1739,10 @@ salvageUncombinableConversion(SILGenFunction &SGF,
17351739
17361740 // Construct the new conversions with the new intermediate type.
17371741 return CombinedConversions (
1738- withNewOutputType (inner, newIntermediateOrigType,
1739- newIntermediateSubstType,
1740- newIntermediateLoweredType),
1741- withNewInputType (outer, newIntermediateOrigType,
1742- newIntermediateSubstType,
1743- newIntermediateLoweredType));
1742+ inner.withResultType (newIntermediateOrigType,
1743+ newIntermediateSubstType,
1744+ newIntermediateLoweredType),
1745+ outer.withSourceType (SGF, newIntermediateSubstType));
17441746 }
17451747 }
17461748
0 commit comments