Skip to content

Commit eb1ea45

Browse files
committed
Soften min version for objcImpl early adopters
Weaken the minimum deployment target error to a warning for objcImpl adopters using the legacy `@_objcImplementation` syntax until we determine exactly how far back it can be safely used. Fixes rdar://129225596.
1 parent 4fc0f3a commit eb1ea45

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,13 @@ visitObjCImplementationAttr(ObjCImplementationAttr *attr) {
16741674
// supported.
16751675
auto deploymentAvailability = AvailabilityContext::forDeploymentTarget(Ctx);
16761676
if (!deploymentAvailability.isContainedIn(Ctx.getSwift50Availability())) {
1677-
diagnose(attr->getLocation(),
1677+
auto diag = diagnose(attr->getLocation(),
16781678
diag::attr_objc_implementation_raise_minimum_deployment_target,
16791679
prettyPlatformString(targetPlatform(Ctx.LangOpts)),
16801680
Ctx.getSwift50Availability().getOSVersion().getLowerEndpoint());
1681+
if (attr->isEarlyAdopter()) {
1682+
diag.wrapIn(diag::wrap_objc_implementation_will_become_error);
1683+
}
16811684
}
16821685
}
16831686
else if (auto AFD = dyn_cast<AbstractFunctionDecl>(D)) {
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
// Hardcode x86_64 macOS because Apple Silicon was born ABI-stable
2-
// RUN: %target-typecheck-verify-swift -import-objc-header %S/Inputs/objc_implementation.h -target x86_64-apple-macosx10.14.3
2+
// RUN: %target-typecheck-verify-swift -import-objc-header %S/Inputs/objc_implementation.h -target x86_64-apple-macosx10.14.3 -enable-experimental-feature ObjCImplementation
33
// REQUIRES: objc_interop
44
// REQUIRES: OS=macosx
55

6-
@_objcImplementation extension ObjCImplSubclass {
6+
@objc @implementation extension ObjCImplSubclass {
77
// expected-error@-1 {{'@implementation' of an Objective-C class requires a minimum deployment target of at least macOS 10.14.4}}
88
}
99

10-
@_objcImplementation(Conformance) extension ObjCClass {
10+
@objc(Conformance) @implementation extension ObjCClass {
1111
// expected-error@-1 {{'@implementation' of an Objective-C class requires a minimum deployment target of at least macOS 10.14.4}}
1212
func requiredMethod1() {}
1313
func requiredMethod2() {}
1414
}
15+
16+
@_objcImplementation(EmptyCategory) extension ObjCClass {
17+
// expected-warning@-1 {{'@implementation' of an Objective-C class requires a minimum deployment target of at least macOS 10.14.4; this will become an error after adopting '@implementation'}}
18+
// expected-warning@-2 {{'@_objcImplementation' is deprecated; use '@implementation' instead}}
19+
}

0 commit comments

Comments
 (0)