Skip to content

Commit c19aadd

Browse files
committed
Enable @objc @implementation feature
1 parent 11696cd commit c19aadd

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and resul
201201
LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
202202
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
203203
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")
204+
LANGUAGE_FEATURE(ObjCImplementation, 436, "@objc @implementation extensions")
204205

205206
// Swift 6
206207
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -378,9 +379,6 @@ EXPERIMENTAL_FEATURE(ClosureIsolation, true)
378379
// Whether lookup of members respects the enclosing file's imports.
379380
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(MemberImportVisibility, true)
380381

381-
// Enable @implementation on extensions of ObjC classes.
382-
EXPERIMENTAL_FEATURE(ObjCImplementation, true)
383-
384382
// Enable @implementation on extensions of ObjC classes with non-fixed layout
385383
// due to resilient stored properties. Requires OS support; this flag exists for
386384
// staging purposes.

test/IRGen/objc_implementation_deployment_target_resilience.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -target %target-stable-abi-triple -I %S/Inputs/abi -F %clang-importer-sdk-path/frameworks %s -import-objc-header %S/Inputs/objc_implementation.h -emit-ir -o %t.ir -enable-library-evolution -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple
33
// REQUIRES: objc_interop
44

5-
@_objcImplementation extension ImplClassWithResilientStoredProperty {
5+
@objc @implementation extension ImplClassWithResilientStoredProperty {
66
@objc var beforeInt: Int32 = 0 // no-error
77
final var a: Mirror? // expected-error {{does not support stored properties whose size can change due to library evolution; store this value in an object or 'any' type}}
88
final var b: AnyKeyPath? // no-error

test/decl/ext/objc_implementation_conflicts.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import objc_implementation_private
1212
#endif
1313

14-
@_objcImplementation extension ObjCClass {
14+
@objc @implementation extension ObjCClass {
1515
@objc func method(fromHeader1: CInt) {
1616
// OK, provides an implementation for the header's method.
1717
}
@@ -179,7 +179,7 @@ import objc_implementation_private
179179
let rdar122280735: (@escaping () -> ()) -> Void = { _ in }
180180
}
181181

182-
@_objcImplementation(PresentAdditions) extension ObjCClass {
182+
@objc(PresentAdditions) @implementation extension ObjCClass {
183183
@objc func categoryMethod(fromHeader3: CInt) {
184184
// OK
185185
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
// REQUIRES: objc_interop
22

3-
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -typecheck %s -import-objc-header %S/Inputs/objc_implementation.h 2>&1 | %FileCheck --check-prefixes NO,CHECK %s
4-
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -typecheck %s -import-objc-header %S/Inputs/objc_implementation.h -enable-experimental-feature ObjCImplementation 2>&1 | %FileCheck --check-prefixes YES,CHECK %s
3+
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -typecheck %s -import-objc-header %S/Inputs/objc_implementation.h 2>&1 | %FileCheck %s
54

6-
// NO-NOT: objc_implementation_features.swift:[[@LINE+2]]:{{[0-9]+}}: warning: '@_objcImplementation' is deprecated; use '@implementation' instead
7-
// YES-DAG: objc_implementation_features.swift:[[@LINE+1]]:{{[0-9]+}}: warning: '@_objcImplementation' is deprecated; use '@implementation' instead
5+
// CHECK-DAG: objc_implementation_features.swift:[[@LINE+1]]:{{[0-9]+}}: warning: '@_objcImplementation' is deprecated; use '@implementation' instead
86
@_objcImplementation(EmptyCategory) extension ObjCClass {}
97

108
// CHECK-DAG: objc_implementation_features.swift:[[@LINE+2]]:{{[0-9]+}}: warning: extension for main class interface should provide implementation for instance method 'subclassMethod(fromHeader1:)'; this will become an error after adopting '@implementation'
119
// CHECK-NOT: objc_implementation_features.swift:[[@LINE+1]]:{{[0-9]+}}: warning: '@_objcImplementation' is deprecated; use '@implementation' instead
1210
@_objcImplementation extension ObjCSubclass {}
1311

14-
// CHECK-DAG: objc_implementation_features.swift:[[@LINE+3]]:{{[0-9]+}}: error: extension for main class interface should provide implementation for initializer 'init()'{{$}}
15-
// NO-DAG: objc_implementation_features.swift:[[@LINE+2]]:{{[0-9]+}}: error: 'implementation' attribute is only valid when experimental feature ObjCImplementation is enabled
16-
// YES-NOT: objc_implementation_features.swift:[[@LINE+1]]:{{[0-9]+}}: error: 'implementation' attribute is only valid when experimental feature ObjCImplementation is enabled
12+
// CHECK-DAG: objc_implementation_features.swift:[[@LINE+2]]:{{[0-9]+}}: error: extension for main class interface should provide implementation for initializer 'init()'{{$}}
13+
// CHECK-NOT: objc_implementation_features.swift:[[@LINE+1]]:{{[0-9]+}}: error: 'implementation' attribute is only valid when experimental feature ObjCImplementation is enabled
1714
@objc @implementation extension ObjCBasicInitClass {}

test/decl/ext/objc_implementation_impl_only.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@_implementationOnly import objc_implementation_internal
55

6-
@_objcImplementation extension InternalObjCClass {
6+
@objc @implementation extension InternalObjCClass {
77
@objc public func method(fromHeader1: CInt) {
88
// OK
99
}

0 commit comments

Comments
 (0)