================
@@ -3197,12 +3188,47 @@ def __repr__(self) -> str:
         )
 
 
-availabilityKinds = {
-    0: CompletionChunk.Kind("Available"),
-    1: CompletionChunk.Kind("Deprecated"),
-    2: CompletionChunk.Kind("NotAvailable"),
-    3: CompletionChunk.Kind("NotAccessible"),
-}
+# AvailabilityKindCompat is an exact copy of AvailabilityKind, except for 
__str__
+# This is a temporary measure to keep the string representation the same
+# until we unify the return of CompletionString.availability to be 
AvailabilityKind
+# Note that deriving from AvailabilityKind directly is not possible
+class AvailabilityKindCompat(BaseEnumeration):
+    """
+    Describes the availability of an entity.
+    """
+
+    # Ensure AvailabilityKindCompat is comparable with AvailabilityKind
+    def __eq__(self, other: object) -> bool:
+        if isinstance(other, AvailabilityKind):
+            return self.value == other.value
+        else:
+            return NotImplemented
----------------
DeinAlptraum wrote:

Uh... that's a great question actually. I forgot to add 
`AvailabilityKindCompat` into the `isinstance` check here, so I'll add it.

Just checked the docs again and it seems my comment on the other PR was not 
quite complete: if for `__eq__(a,b)` both `a` and `b` return `NotImplemented`, 
which is what's happening when comparing two `AvailabilityKindCompats`s, then 
it doesn't return `False` immediately, but it falls back to an identity check.
But I doubt many people know that and I don't want to rely on it, so I'll make 
it explicit. Good catch!

https://github.com/llvm/llvm-project/pull/160296
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to