Skip to content

Commit

Permalink
[lldb] Add a test for Obj-C properties with conflicting names
Browse files Browse the repository at this point in the history
This is apparently allowed in Objective-C so we should test this in LLDB.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D99513
  • Loading branch information
Teemperor committed Mar 30, 2021
1 parent 1cbba53 commit 6919c58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ def test_objc_properties(self):
value = frame.EvaluateExpression("BaseClass.classInt", False)
self.assertTrue(value.GetError().Success())
self.assertEquals(value.GetValueAsUnsigned(11111), 234)

# Test that accessing two distinct class and instance properties that
# share the same name works.
self.expect_expr("mine.propConflict", result_value="4")
self.expect_expr("BaseClass.propConflict", result_value="6")
14 changes: 14 additions & 0 deletions lldb/test/API/lang/objc/objc-property/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ - (void) mySetUnbackedInt: (int) in_int;

- (int) getAccessCount;

+ (int) propConflict;

+(BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt;

@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
@property int backedInt;
@property (nonatomic, assign) id <MyProtocol> idWithProtocol;
@property(class) int classInt;
@property(getter=propConflict,readonly) int propConflict;
@property(readonly,class) int propConflict;
@end

@implementation BaseClass
Expand Down Expand Up @@ -85,6 +89,15 @@ - (int) getAccessCount
{
return _access_count;
}

- (int) propConflict
{
return 4;
}
+ (int) propConflict
{
return 6;
}
@end

typedef BaseClass TypedefBaseClass;
Expand All @@ -94,6 +107,7 @@ - (int) getAccessCount
{
BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
TypedefBaseClass *typedefd = mine;
int propConflict = mine.propConflict + BaseClass.propConflict;

// Set a breakpoint here.
int nonexistant = mine.nonexistantInt;
Expand Down

0 comments on commit 6919c58

Please sign in to comment.