Skip to content

[PrintAsObjC] Silence -Wnullability for the generated declarations. #10256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/PrintAsObjC/PrintAsObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,7 @@ class ModuleWriter {
"# pragma clang diagnostic ignored \"-Wpragma-clang-attribute\"\n"
"#endif\n"
"#pragma clang diagnostic ignored \"-Wunknown-pragmas\"\n"
"#pragma clang diagnostic ignored \"-Wnullability\"\n"
"\n"
"SWIFT_MODULE_NAMESPACE_PUSH(\"" << M.getNameStr() << "\")\n"
<< os.str()
Expand Down
14 changes: 0 additions & 14 deletions test/PrintAsObjC/Inputs/custom-modules/NestedClass.apinotes

This file was deleted.

24 changes: 24 additions & 0 deletions test/PrintAsObjC/Inputs/custom-modules/VersionedFMWK.apinotes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Name: VersionedFMWK
SwiftVersions:
- Version: 3.0
Classes:
- Name: InnerClass
SwiftName: InnerClass
- Name: NullabilityBase
Methods:
- Selector: 'initFormerlyFailableValue:'
MethodKind: Instance
NullabilityOfRet: O
- Selector: 'processNowNullableArgument:'
MethodKind: Instance
Parameters:
- Position: 0
Nullability: N
Tags:
- Name: InnerStruct
SwiftName: InnerStruct
Typedefs:
- Name: InnerAlias
SwiftName: InnerAlias
- Name: InnerAnonStruct
SwiftName: InnerAnonStruct
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ typedef struct {

typedef int InnerAlias __attribute__((swift_name("Outer.InnerA")));


@interface NullabilityBase : NSObject
- (nonnull instancetype)initFormerlyFailableValue:(NSInteger)value __attribute__((objc_designated_initializer));
- (void)processNowNullableArgument:(nullable NSObject *)object;
@end
4 changes: 2 additions & 2 deletions test/PrintAsObjC/Inputs/custom-modules/module.map
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module CompatibilityAlias {
export *
}

module NestedClass {
header "NestedClass.h"
module VersionedFMWK {
header "VersionedFMWK.h"
export *
}
11 changes: 9 additions & 2 deletions test/PrintAsObjC/versioned.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -parse-as-library %t/versioned.swiftmodule -typecheck -I %S/Inputs/custom-modules -emit-objc-header-path %t/versioned.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -swift-version 3
// RUN: %FileCheck %s < %t/versioned.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ %t/versioned.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/versioned.h -include Foundation.h -include NestedClass.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/versioned.h -include Foundation.h -include VersionedFMWK.h

import NestedClass
import VersionedFMWK

// CHECK-LABEL: @interface NullabilitySub
@objc class NullabilitySub: NullabilityBase {
// CHECK-NEXT: - (void)processNowNullableArgument:(NSObject * _Nonnull)object;
override func processNowNullableArgument(_ object: NSObject) {}
// CHECK-NEXT: - (nullable instancetype)initFormerlyFailableValue:(NSInteger)value OBJC_DESIGNATED_INITIALIZER;
} // CHECK-NEXT: @end

// CHECK-LABEL: @interface UsesNestedClass
@objc class UsesNestedClass : NSObject {
Expand Down