Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ typedef struct SomeStruct_s {
@interface MyDerivedClass : MyBaseClass
@property (nonatomic, strong, nullable) Base *derivedMember;
@end

typedef enum {
Caster,
Grantulated,
Confectioners,
Cane,
Demerara,
Turbinado,
} RefinedSugar /*NS_REFINED_FOR_SWIFT*/ __attribute__((swift_private));

@interface Refinery : Base
@property (nonatomic, readonly) RefinedSugar sugar /*NS_REFINED_FOR_SWIFT*/ __attribute__((swift_private));
@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@

@interface MyBaseClass () <MyPrivateProtocol>
@end

@interface Refinery ()
@property (nonatomic, readwrite) RefinedSugar sugar;
@end
30 changes: 27 additions & 3 deletions test/ClangImporter/objc_redeclared_properties_categories.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -F %S/Inputs/frameworks %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PUBLIC %s

// RUN: echo '#import <CategoryOverrides/Private.h>' > %t.h
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s --allow-empty
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s --allow-empty

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-pch -F %S/Inputs/frameworks -o %t.pch %t.h
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s

import CategoryOverrides

Expand Down Expand Up @@ -54,3 +54,27 @@ func takesABaseClass(_ x: MyBaseClass) {
// CHECK-PRIVATE-NOT: has no member 'derivedMember'
x.derivedMember = Base()
}

// A category declared in a (private) header can introduce overrides of a
// property that has mismatched Swift naming conventions. If we see a
// non-__attribute__((swift_private)) decl, sometimes it comes in too.

extension Refinery {
public enum RefinedSugar {
case caster
case grantulated
case confectioners
case cane
case demerara
case turbinado
}

public var sugar: Refinery.RefinedSugar {
return .caster // RefinedSugar(self.__sugar)
}
}

func takesARefinery(_ x: Refinery) {
// CHECK: cannot assign to property: 'sugar' is a get-only property
x.sugar = .caster
}