@@ -1546,39 +1546,43 @@ static bool isMatchedAnyToAnyObjectConversion(CanType from, CanType to) {
1546
1546
return false ;
1547
1547
}
1548
1548
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 ());
1562
1566
default :
1563
- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1567
+ llvm_unreachable (" operation not supported on specialized bridging "
1568
+ " conversions" );
1564
1569
}
1565
1570
}
1566
1571
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);
1580
1583
default :
1581
- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1584
+ llvm_unreachable (" operation not supported on specialized bridging "
1585
+ " conversions" );
1582
1586
}
1583
1587
}
1584
1588
@@ -1743,12 +1747,10 @@ salvageUncombinableConversion(SILGenFunction &SGF,
1743
1747
1744
1748
// Construct the new conversions with the new intermediate type.
1745
1749
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));
1752
1754
}
1753
1755
}
1754
1756
0 commit comments