Skip to content

Commit 04d47dc

Browse files
authored
Merge pull request swiftlang#29831 from CodaFi/protocol-dictates-action
[ClangImporter] Commit a regression test for protocols via nested names
2 parents 84ec27c + a72c5fa commit 04d47dc

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@protocol TrunkBranchProtocol;
2+
3+
__attribute__((objc_root_class))
4+
@interface Trunk
5+
- (instancetype)init;
6+
- (void)addLimb:(id<TrunkBranchProtocol>)limb;
7+
@end
8+
9+
// NS_SWIFT_NAME(Trunk.Branch)
10+
__attribute__((swift_name("Trunk.Branch")))
11+
@protocol TrunkBranchProtocol
12+
- (void) flower;
13+
@end
14+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// REQUIRES: objc_interop
2+
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -import-objc-header %S/Inputs/nested_protocol_name.h -typecheck -verify %s
4+
5+
// RUN: echo '#include "nested_protocol_name.h"' > %t.m
6+
// RUN: %target-swift-ide-test -source-filename %s -print-header -header-to-print %S/Inputs/nested_protocol_name.h -import-objc-header %S/Inputs/nested_protocol_name.h -print-regular-comments --cc-args %target-cc-options -fsyntax-only %t.m -I %S/Inputs > %t.txt
7+
// RUN: %FileCheck -check-prefix=HEADER %s < %t.txt
8+
9+
// rdar://59431058
10+
// Let's make sure this works, but let's not encourage its spread...
11+
12+
// HEADER: class Trunk {
13+
// HEADER: init!()
14+
// HEADER: class func addLimb(_ limb: Branch!)
15+
// HEADER: func addLimb(_ limb: Branch!)
16+
// HEADER: }
17+
// HEADER: // NS_SWIFT_NAME(Trunk.Branch)
18+
// HEADER: protocol Branch {
19+
// HEADER: func flower()
20+
// HEADER: }
21+
22+
func grow(_ branch: Trunk.Branch, from trunk: Trunk) {
23+
branch.flower()
24+
trunk.addLimb(branch)
25+
}
26+
27+
class SturdyBranch: Trunk.Branch {
28+
func flower() {}
29+
}
30+
31+
// FIXME: Odd that name lookup can't find this...
32+
class NormalBranch: Branch { // expected-error {{use of undeclared type 'Branch'}}
33+
func flower() {}
34+
}
35+
36+
class WeakBranch: TrunkBranchProtocol { // expected-error {{'TrunkBranchProtocol' has been renamed to 'Trunk.Branch'}}
37+
func flower() {}
38+
}

0 commit comments

Comments
 (0)