@@ -1546,39 +1546,43 @@ static bool isMatchedAnyToAnyObjectConversion(CanType from, CanType to) {
15461546 return false ;
15471547}
15481548
1549- static Conversion withNewInputType (const Conversion &conv,
1550- AbstractionPattern origType,
1551- CanType substType,
1552- SILType loweredType) {
1553- switch (conv.getKind ()) {
1554- case Conversion::Reabstract:
1555- return Conversion::getReabstract (origType, substType, loweredType,
1556- conv.getReabstractionOutputOrigType (),
1557- conv.getReabstractionOutputSubstType (),
1558- conv.getReabstractionOutputLoweredType ());
1559- case Conversion::Subtype:
1560- return Conversion::getSubtype (substType, conv.getBridgingResultType (),
1561- conv.getBridgingLoweredResultType ());
1549+ Conversion
1550+ Conversion::withSourceType (SILGenFunction &SGF, CanType substType) const {
1551+ return withSourceType (AbstractionPattern (substType), substType,
1552+ SGF.getLoweredType (substType));
1553+ }
1554+
1555+ Conversion
1556+ Conversion::withSourceType (AbstractionPattern origType,
1557+ CanType substType, SILType loweredType) const {
1558+ switch (getKind ()) {
1559+ case Reabstract:
1560+ return getReabstract (origType, substType, loweredType,
1561+ getReabstractionOutputOrigType (),
1562+ getReabstractionOutputSubstType (),
1563+ getReabstractionOutputLoweredType ());
1564+ case Subtype:
1565+ return getSubtype (substType, getResultType (), getLoweredResultType ());
15621566 default :
1563- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1567+ llvm_unreachable (" operation not supported on specialized bridging "
1568+ " conversions" );
15641569 }
15651570}
15661571
1567- static Conversion withNewOutputType (const Conversion &conv,
1568- AbstractionPattern origType,
1569- CanType substType,
1570- SILType loweredType) {
1571- switch (conv.getKind ()) {
1572- case Conversion::Reabstract:
1573- return Conversion::getReabstract (conv.getReabstractionInputOrigType (),
1574- conv.getReabstractionInputSubstType (),
1575- conv.getReabstractionInputLoweredType (),
1576- origType, substType, loweredType);
1577- case Conversion::Subtype:
1578- return Conversion::getSubtype (conv.getBridgingSourceType (),
1579- substType, loweredType);
1572+ Conversion
1573+ Conversion::withResultType (AbstractionPattern origType,
1574+ CanType substType, SILType loweredType) const {
1575+ switch (getKind ()) {
1576+ case Reabstract:
1577+ return getReabstract (getReabstractionInputOrigType (),
1578+ getReabstractionInputSubstType (),
1579+ getReabstractionInputLoweredType (),
1580+ origType, substType, loweredType);
1581+ case Subtype:
1582+ return getSubtype (getSourceType (), substType, loweredType);
15801583 default :
1581- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1584+ llvm_unreachable (" operation not supported on specialized bridging "
1585+ " conversions" );
15821586 }
15831587}
15841588
@@ -1743,12 +1747,10 @@ salvageUncombinableConversion(SILGenFunction &SGF,
17431747
17441748 // Construct the new conversions with the new intermediate type.
17451749 return CombinedConversions (
1746- withNewOutputType (inner, newIntermediateOrigType,
1747- newIntermediateSubstType,
1748- newIntermediateLoweredType),
1749- withNewInputType (outer, newIntermediateOrigType,
1750- newIntermediateSubstType,
1751- newIntermediateLoweredType));
1750+ inner.withResultType (newIntermediateOrigType,
1751+ newIntermediateSubstType,
1752+ newIntermediateLoweredType),
1753+ outer.withSourceType (SGF, newIntermediateSubstType));
17521754 }
17531755 }
17541756
0 commit comments