Skip to content

Commit 2e47272

Browse files
authored
[PrintAsObjC] Don't warn about inferred '@objc' in Swift 3 mode. (#9756)
Only do so in modes where '@objc' /is/ inferred but we're supposed to warn about it. Neither plain old Swift 3 nor plain old Swift 4 are in this state, but we have frontend options that allow us to set that up for migration purposes. rdar://problem/32284936
1 parent 4ec2838 commit 2e47272

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
809809
}
810810

811811
void printSwift3ObjCDeprecatedInference(ValueDecl *VD) {
812+
const LangOptions &langOpts = M.getASTContext().LangOpts;
813+
if (!langOpts.EnableSwift3ObjCInference ||
814+
langOpts.WarnSwift3ObjCInference == Swift3ObjCInferenceWarnings::None) {
815+
return;
816+
}
812817
auto attr = VD->getAttrs().getAttribute<ObjCAttr>();
813818
if (!attr || !attr->isSwift3Inferred())
814819
return;

test/PrintAsObjC/swift3_deprecated_objc_inference.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111
// FIXME: END -enable-source-import hackaround
1212

1313

14-
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -I %S/Inputs/custom-modules -o %t %s -disable-objc-attr-requires-foundation-module -swift-version 3
15-
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -parse-as-library %t/swift3_deprecated_objc_inference.swiftmodule -typecheck -I %S/Inputs/custom-modules -emit-objc-header-path %t/swift3_deprecated_objc_inference.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -swift-version 3
14+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -I %S/Inputs/custom-modules -o %t %s -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-swift3-objc-inference -warn-swift3-objc-inference-minimal
15+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -parse-as-library %t/swift3_deprecated_objc_inference.swiftmodule -typecheck -I %S/Inputs/custom-modules -emit-objc-header-path %t/swift3_deprecated_objc_inference.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-swift3-objc-inference -warn-swift3-objc-inference-minimal
1616
// RUN: %FileCheck %s < %t/swift3_deprecated_objc_inference.h
1717
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ %t/swift3_deprecated_objc_inference.h
1818

19+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -I %S/Inputs/custom-modules -o %t/swift3_deprecated_objc_inference_nowarn.swiftmodule %s -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-swift3-objc-inference
20+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -parse-as-library %t/swift3_deprecated_objc_inference_nowarn.swiftmodule -typecheck -I %S/Inputs/custom-modules -emit-objc-header-path %t/swift3_deprecated_objc_inference_nowarn.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-swift3-objc-inference
21+
// RUN: %FileCheck -check-prefix=CHECK-NOWARN %s < %t/swift3_deprecated_objc_inference_nowarn.h
22+
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ %t/swift3_deprecated_objc_inference_nowarn.h
23+
1924
import Foundation
2025

26+
// CHECK-NOWARN-NOT: @objc
27+
2128
// CHECK-LABEL: @interface A1{{$}}
2229
// CHECK-NEXT: init
2330
// CHECK-NEXT: @end

0 commit comments

Comments
 (0)