Skip to content

Commit c5ba171

Browse files
authored
Merge pull request #35586 from DougGregor/objc-async-extended-type-descriptors
[Concurrency] Emit extended method type descriptors for @objc async methods
2 parents 5427986 + 21f9539 commit c5ba171

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/IRGen/GenObjC.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ irgen::emitObjCMethodDescriptorParts(IRGenModule &IGM,
11851185
/// elements.
11861186
CanSILFunctionType methodType = getObjCMethodType(IGM, method);
11871187
descriptor.typeEncoding =
1188-
getObjCEncodingForMethod(IGM, methodType, /*extended*/ false, method);
1188+
getObjCEncodingForMethod(IGM, methodType, /*extended*/ method->hasAsync(),
1189+
method);
11891190

11901191
/// The third element is the method implementation pointer.
11911192
if (!concrete) {

test/IRGen/objc_async_metadata.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %build-irgen-test-overlays
3+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -enable-experimental-concurrency %s -emit-ir | %FileCheck %s
4+
5+
// REQUIRES: OS=macosx
6+
// REQUIRES: concurrency
7+
// REQUIRES: objc_interop
8+
9+
10+
import Foundation
11+
12+
// CHECK: [[ENCODE_ASYNC_STRING:@.*]] = private unnamed_addr constant [28 x i8] c"v24@0:8@?<v@?@\22NSString\22>16\00"
13+
// CHECK: [[ENCODE_ASYNC_THROWS_STRING:@.*]] = private unnamed_addr constant [38 x i8] c"v24@0:8@?<v@?@\22NSString\22@\22NSError\22>16\00"
14+
15+
// CHECK: @_INSTANCE_METHODS__TtC19objc_async_metadata7MyClass = internal constant
16+
// CHECK-SAME: methodWithCompletionHandler:
17+
// CHECK-SAME: [[ENCODE_ASYNC_STRING]]
18+
// CHECK-SAME: throwingMethodWithCompletionHandler:
19+
// CHECK-SAME: [[ENCODE_ASYNC_THROWS_STRING]]
20+
class MyClass: NSObject {
21+
@objc func method() async -> String { "" }
22+
@objc func throwingMethod() async throws -> String { "" }
23+
}

0 commit comments

Comments
 (0)