[lldb] Add a test for Obj-C properties with conflicting names
authorRaphael Isemann <teemperor@gmail.com>
Tue, 30 Mar 2021 09:08:08 +0000 (11:08 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Tue, 30 Mar 2021 09:08:16 +0000 (11:08 +0200)
This is apparently allowed in Objective-C so we should test this in LLDB.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D99513

lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
lldb/test/API/lang/objc/objc-property/main.m

index 5693a77..25158a5 100644 (file)
@@ -137,3 +137,8 @@ class ObjCPropertyTestCase(TestBase):
         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")
index 8c84440..94e5af4 100644 (file)
@@ -22,12 +22,16 @@ static int _class_int = 123;
 
 - (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
@@ -85,6 +89,15 @@ static int _class_int = 123;
 {
   return _access_count;
 }
+
+- (int) propConflict
+{
+  return 4;
+}
++ (int) propConflict
+{
+  return 6;
+}
 @end
 
 typedef BaseClass TypedefBaseClass;
@@ -94,6 +107,7 @@ main ()
 {
   BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
   TypedefBaseClass *typedefd = mine;
+  int propConflict = mine.propConflict + BaseClass.propConflict;
   
   // Set a breakpoint here.
   int nonexistant = mine.nonexistantInt;