@@ -1578,26 +1578,22 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1578
1578
// Is a SIL type a potential lowering of a formal type?
1579
1579
static bool isLoweringOf (SILType loweredType,
1580
1580
CanType formalType) {
1581
+
1582
+
1581
1583
// Dynamic self has the same lowering as its contained type.
1582
1584
if (auto dynamicSelf = dyn_cast<DynamicSelfType>(formalType))
1583
1585
formalType = CanType (dynamicSelf->getSelfType ());
1584
1586
1585
- // Optional of dynamic self has the same lowering as its contained type.
1586
- OptionalTypeKind loweredOptionalKind;
1587
- OptionalTypeKind formalOptionalKind;
1588
-
1589
- CanType loweredObjectType = loweredType.getSwiftRValueType ()
1590
- .getAnyOptionalObjectType (loweredOptionalKind);
1587
+ // Optional lowers its contained type. The difference between Optional
1588
+ // and IUO is lowered away.
1589
+ SILType loweredObjectType = loweredType
1590
+ .getAnyOptionalObjectType ();
1591
1591
CanType formalObjectType = formalType
1592
- .getAnyOptionalObjectType (formalOptionalKind );
1592
+ .getAnyOptionalObjectType ();
1593
1593
1594
- if (loweredOptionalKind != OTK_None) {
1595
- if (auto dynamicSelf = dyn_cast<DynamicSelfType>(formalObjectType)) {
1596
- formalObjectType = dynamicSelf->getSelfType ()->getCanonicalType ();
1597
- }
1598
- return loweredOptionalKind == formalOptionalKind &&
1599
- isLoweringOf (SILType::getPrimitiveAddressType (loweredObjectType),
1600
- formalObjectType);
1594
+ if (loweredObjectType) {
1595
+ return formalObjectType &&
1596
+ isLoweringOf (loweredObjectType, formalObjectType);
1601
1597
}
1602
1598
1603
1599
// Metatypes preserve their instance type through lowering.
0 commit comments