File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1067,6 +1067,9 @@ class alignas(1 << TypeAlignInBits) TypeBase {
1067
1067
// otherwise, return the null type.
1068
1068
Type getSwiftNewtypeUnderlyingType ();
1069
1069
1070
+ // / Return the type T after looking through at most one optional type.
1071
+ Type lookThroughSingleOptionalType ();
1072
+
1070
1073
// / Return the type T after looking through all of the optional
1071
1074
// / types.
1072
1075
Type lookThroughAllOptionalTypes ();
Original file line number Diff line number Diff line change @@ -670,6 +670,13 @@ Type TypeBase::getAnyBufferPointerElementType(BufferPointerTypeKind &BPTK) {
670
670
return Type ();
671
671
}
672
672
673
+ Type TypeBase::lookThroughSingleOptionalType () {
674
+ Type type (this );
675
+ if (auto objType = type->getOptionalObjectType ())
676
+ type = objType;
677
+ return type;
678
+ }
679
+
673
680
Type TypeBase::lookThroughAllOptionalTypes () {
674
681
Type type (this );
675
682
while (auto objType = type->getOptionalObjectType ())
Original file line number Diff line number Diff line change @@ -7241,10 +7241,8 @@ ConstraintSystem::simplifyDynamicCallableApplicableFnConstraint(
7241
7241
}
7242
7242
7243
7243
static Type getBaseTypeForPointer (ConstraintSystem &cs, TypeBase *type) {
7244
- if (Type unwrapped = type->getOptionalObjectType ())
7245
- type = unwrapped.getPointer ();
7246
-
7247
- auto pointeeTy = type->getAnyPointerElementType ();
7244
+ auto pointeeTy = type->lookThroughSingleOptionalType ()
7245
+ ->getAnyPointerElementType ();
7248
7246
assert (pointeeTy);
7249
7247
return pointeeTy;
7250
7248
}
You can’t perform that action at this time.
0 commit comments