mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When an @_implementationOnly import includes Objective-C categories for existing types, it's useful to be able to override the members provided in those categories without exposing them to clients of the framework being built. Allow this as long as the overriding declaration is marked as @_implementationOnly itself, with an additional check that the type of the declaration does not change. (Normally overrides are allowed to change in covariant ways.) Part of rdar://50827914
70 lines
2.3 KiB
Swift
70 lines
2.3 KiB
Swift
// Please keep this file in alphabetical order!
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/custom-modules/ -F %S/Inputs/ -emit-module -o %t %s -disable-objc-attr-requires-foundation-module
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/custom-modules/ -F %S/Inputs/ -parse-as-library %t/imports.swiftmodule -typecheck -emit-objc-header-path %t/imports.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
|
|
// RUN: %FileCheck %s < %t/imports.h
|
|
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/imports.h
|
|
// RUN: %check-in-clang %t/imports.h -I %S/Inputs/custom-modules/ -F %S/Inputs/ -Watimport-in-framework-header
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
// CHECK: @import Base;
|
|
// CHECK-NEXT: @import Base.ExplicitSub;
|
|
// CHECK-NEXT: @import Base.ExplicitSub.ExSub;
|
|
// CHECK-NEXT: @import Base.ImplicitSub.ExSub;
|
|
// CHECK-NEXT: @import Foundation;
|
|
// CHECK-NEXT: @import MostlyPrivate1;
|
|
// CHECK-NEXT: @import MostlyPrivate1_Private;
|
|
// CHECK-NEXT: @import MostlyPrivate2_Private;
|
|
// CHECK-NEXT: @import ObjectiveC;
|
|
// CHECK-NEXT: @import ctypes.bits;
|
|
|
|
// NEGATIVE-NOT: ctypes;
|
|
// NEGATIVE-NOT: ImSub;
|
|
// NEGATIVE-NOT: ImplicitSub;
|
|
// NEGATIVE-NOT: MostlyPrivate2;
|
|
// NEGATIVE-NOT: MiserablePileOfSecrets;
|
|
|
|
// NEGATIVE-NOT: secretMethod
|
|
|
|
import ctypes.bits
|
|
import Foundation
|
|
|
|
import Base
|
|
import Base.ImplicitSub
|
|
import Base.ImplicitSub.ImSub
|
|
import Base.ImplicitSub.ExSub
|
|
import Base.ExplicitSub
|
|
import Base.ExplicitSub.ImSub
|
|
import Base.ExplicitSub.ExSub
|
|
|
|
import MostlyPrivate1
|
|
import MostlyPrivate1_Private
|
|
// Deliberately not importing MostlyPrivate2
|
|
import MostlyPrivate2_Private
|
|
|
|
@_implementationOnly import MiserablePileOfSecrets
|
|
|
|
@objc class Test {
|
|
@objc let word: DWORD = 0
|
|
@objc let number: TimeInterval = 0.0
|
|
|
|
@objc let baseI: BaseI = 0
|
|
@objc let baseII: BaseII = 0
|
|
@objc let baseIE: BaseIE = 0
|
|
@objc let baseE: BaseE = 0
|
|
@objc let baseEI: BaseEI = 0
|
|
@objc let baseEE: BaseEE = 0
|
|
|
|
// Deliberately use the private type before the public type.
|
|
@objc let mp1priv: MP1PrivateType = 0
|
|
@objc let mp1pub: MP1PublicType = 0
|
|
|
|
@objc let mp2priv: MP2PrivateType = 0
|
|
}
|
|
|
|
@objc public class TestSubclass: NSObject {
|
|
@_implementationOnly public override func secretMethod() {}
|
|
}
|