Skip to content

Commit 931a5df

Browse files
Merge pull request swiftlang#38825 from nate-chandler/rdar81625544
[SIL] Fixed return index for call-as-async (BOOL, Error, Value) case.
2 parents 9bb056b + e349fd0 commit 931a5df

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,14 @@ AbstractionPattern AbstractionPattern::getFunctionResultType() const {
574574
// If there's a single argument, abstract it according to its formal type
575575
// in the ObjC signature.
576576
unsigned callbackResultIndex = 0;
577-
if (callbackErrorIndex && callbackResultIndex >= *callbackErrorIndex)
578-
++callbackResultIndex;
579-
if (callbackErrorFlagIndex
580-
&& callbackResultIndex >= *callbackErrorFlagIndex)
581-
++callbackResultIndex;
582-
577+
for (auto index : indices(callbackParamTy->getParamTypes())) {
578+
if (callbackErrorIndex && index == *callbackErrorIndex)
579+
continue;
580+
if (callbackErrorFlagIndex && index == *callbackErrorFlagIndex)
581+
continue;
582+
callbackResultIndex = index;
583+
break;
584+
}
583585
auto clangResultType = callbackParamTy
584586
->getParamType(callbackResultIndex)
585587
.getTypePtr();

validation-test/compiler_crashers_2_fixed/rdar81617749.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ func run(on object: PFXObject) async throws {
2525
// CHECK: performSingleBothy13
2626
print(try await object.performSingleBothy13()())
2727

28-
// Reenable with rdar://81625544
29-
// CHECK performSingleBothy21
30-
// print(try await object.performSingleBothy21()())
28+
// CHECK: performSingleBothy21
29+
print(try await object.performSingleBothy21()())
3130

3231
// CHECK: performSingleBothy23
3332
print(try await object.performSingleBothy23()())

0 commit comments

Comments
 (0)