Skip to content

Commit e8492e9

Browse files
committed
Simplify code as per review
1 parent a58a980 commit e8492e9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,20 +1426,18 @@ static void convertBBArgType(SILBuilder &argBuilder, SILType newSILType,
14261426
}
14271427
}
14281428

1429-
static bool containsFunctionType(SILType ty) {
1430-
if (auto tuple = ty.getAs<TupleType>()) {
1431-
for (TupleTypeElt elem : tuple->getElements()) {
1432-
auto canElem = CanType(elem.getRawType());
1433-
auto elemTy = SILType::getPrimitiveObjectType(canElem);
1434-
if (containsFunctionType(elemTy))
1429+
static bool containsFunctionType(CanType ty) {
1430+
if (auto tuple = dyn_cast<TupleType>(ty)) {
1431+
for (auto elt : tuple.getElementTypes()) {
1432+
if (containsFunctionType(elt))
14351433
return true;
14361434
}
14371435
return false;
14381436
}
14391437
if (auto optionalType = ty.getOptionalObjectType()) {
14401438
return containsFunctionType(optionalType);
14411439
}
1442-
return ty.is<SILFunctionType>();
1440+
return isa<SILFunctionType>(ty);
14431441
}
14441442

14451443
void LoadableStorageAllocation::convertApplyResults() {
@@ -1466,7 +1464,7 @@ void LoadableStorageAllocation::convertApplyResults() {
14661464
auto numFuncTy = llvm::count_if(origSILFunctionType->getResults(),
14671465
[](const SILResultInfo &origResult) {
14681466
auto resultStorageTy = origResult.getSILStorageType();
1469-
return containsFunctionType(resultStorageTy);
1467+
return containsFunctionType(resultStorageTy.getASTType());
14701468
});
14711469
assert(numFuncTy != 0 &&
14721470
"Expected a SILFunctionType inside the result Type");

0 commit comments

Comments
 (0)