Skip to content

Commit 33452e1

Browse files
authored
Merge pull request #34503 from DougGregor/async-type-lower-void
[async type lowering] Handle Void return from @objc async methods.
2 parents fd0012e + f30778f commit 33452e1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,17 @@ AbstractionPattern AbstractionPattern::getFunctionResultType() const {
532532
callbackResultIndex = 1;
533533
}
534534
}
535+
536+
const clang::Type *clangResultType = nullptr;
537+
if (callbackResultIndex < callbackParamTy->getNumParams()) {
538+
clangResultType = callbackParamTy->getParamType(callbackResultIndex)
539+
.getTypePtr();
540+
} else {
541+
clangResultType = getObjCMethod()->getASTContext().VoidTy.getTypePtr();
542+
}
543+
535544
return AbstractionPattern(getGenericSignatureForFunctionComponent(),
536-
getResultType(getType()),
537-
callbackParamTy->getParamType(callbackResultIndex)
538-
.getTypePtr());
545+
getResultType(getType()), clangResultType);
539546
}
540547

541548
return AbstractionPattern(getGenericSignatureForFunctionComponent(),

test/SILGen/objc_async.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -enable-experimental-concurrency %s -verify
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -enable-experimental-concurrency %s -verify | %FileCheck %s
22
// REQUIRES: objc_interop
33

44
import Foundation
@@ -10,4 +10,7 @@ func testSlowServer(slowServer: SlowServer) async throws {
1010
let _: Int = await slowServer.doSomethingSlow("mail")
1111
// CHECK: objc_method {{.*}} $@convention(objc_method) (@convention(block) (Optional<NSString>, Optional<NSError>) -> (), SlowServer) -> ()
1212
let _: String? = try await slowServer.findAnswer()
13+
14+
// CHECK: objc_method {{.*}} $@convention(objc_method) (NSString, @convention(block) () -> (), SlowServer) -> ()
15+
await slowServer.serverRestart("somewhere")
1316
}

0 commit comments

Comments
 (0)