Skip to content

Commit c700e2e

Browse files
committed
[NamedLazyMemberLoading] Add testcase for categories.
1 parent 2a2473d commit c700e2e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

test/NameBinding/Inputs/NamedLazyMembers/NamedLazyMembers.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@
5151
@end
5252

5353

54+
// Don't conform to the protocol; that loads all protocol members.
55+
@interface SimpleDoer (Category)
56+
- (void)categoricallyDoSomeWork;
57+
- (void)categoricallyDoSomeWorkWithSpeed:(int)s;
58+
- (void)categoricallyDoSomeWorkWithSpeed:(int)s thoroughness:(int)t
59+
NS_SWIFT_NAME(categoricallyDoVeryImportantWork(speed:thoroughness:));
60+
- (void)categoricallyDoSomeWorkWithSpeed:(int)s alacrity:(int)a
61+
NS_SWIFT_NAME(categoricallyDoSomeWorkWithSpeed(speed:levelOfAlacrity:));
62+
63+
// These we are generally trying to not-import, via laziness.
64+
- (void)categoricallyGoForWalk;
65+
- (void)categoricallyTakeNap;
66+
- (void)categoricallyEatMeal;
67+
- (void)categoricallyTidyHome;
68+
- (void)categoricallyCallFamily;
69+
- (void)categoricallySingSong;
70+
- (void)categoricallyReadBook;
71+
- (void)categoricallyAttendLecture;
72+
- (void)categoricallyWriteLetter;
73+
@end
74+
75+
5476
@protocol MirroredBase
5577
+ (void)mirroredBaseClassMethod;
5678
- (void)mirroredBaseInstanceMethod;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// REQUIRES: objc_interop
2+
// REQUIRES: OS=macosx
3+
// RUN: rm -rf %t && mkdir -p %t/stats-pre && mkdir -p %t/stats-post
4+
//
5+
// Prime module cache
6+
// RUN: %target-swift-frontend -typecheck -I %S/Inputs/NamedLazyMembers -typecheck %s
7+
//
8+
// Check that named-lazy-member-loading reduces the number of Decls deserialized
9+
// RUN: %target-swift-frontend -typecheck -I %S/Inputs/NamedLazyMembers -disable-named-lazy-member-loading -stats-output-dir %t/stats-pre %s
10+
// RUN: %target-swift-frontend -typecheck -I %S/Inputs/NamedLazyMembers -stats-output-dir %t/stats-post %s
11+
// RUN: %utils/process-stats-dir.py --evaluate-delta 'NumTotalClangImportedEntities < -10' %t/stats-pre %t/stats-post
12+
13+
import NamedLazyMembers
14+
15+
public func foo(d: SimpleDoer) {
16+
let _ = d.categoricallyDoSomeWork()
17+
let _ = d.categoricallyDoSomeWork(withSpeed:10)
18+
let _ = d.categoricallyDoVeryImportantWork(speed:10, thoroughness:12)
19+
let _ = d.categoricallyDoSomeWorkWithSpeed(speed:10, levelOfAlacrity:12)
20+
}

0 commit comments

Comments
 (0)