@@ -1538,39 +1538,43 @@ static bool isMatchedAnyToAnyObjectConversion(CanType from, CanType to) {
1538
1538
return false ;
1539
1539
}
1540
1540
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 ());
1554
1558
default :
1555
- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1559
+ llvm_unreachable (" operation not supported on specialized bridging "
1560
+ " conversions" );
1556
1561
}
1557
1562
}
1558
1563
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);
1572
1575
default :
1573
- llvm_unreachable (" shouldn't be trying to combine these kinds" );
1576
+ llvm_unreachable (" operation not supported on specialized bridging "
1577
+ " conversions" );
1574
1578
}
1575
1579
}
1576
1580
@@ -1735,12 +1739,10 @@ salvageUncombinableConversion(SILGenFunction &SGF,
1735
1739
1736
1740
// Construct the new conversions with the new intermediate type.
1737
1741
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));
1744
1746
}
1745
1747
}
1746
1748
0 commit comments