Uploaded image for project: 'Swift'
  1. Swift
  2. SR-13056

Equality of Void via AnyObject only checks for pointer equality

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler, Foundation
    • Labels:
    • Environment:

      Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
      Target: x86_64-apple-darwin19.5.0

      Description

      Compare thisĀ 

      import Foundation
      let unit: () = ()
      let unitAny = unit as Any
      let unitObject1 = unit as AnyObject
      let unitObject2 = unit as AnyObject
      unit == unit                      // true
      unitObject1.isEqual(unit)         // false
      unitObject1.isEqual(unitObject1)  // true
      unitObject1.isEqual(unitObject2)  // false
      

      with

      import Foundation
      let num = 12345678987
      let numAny = num as Any
      let numObject1 = num as AnyObject
      let numObject2 = num as AnyObject
      num == num                      // true
      numObject1.isEqual(num)         // true
      numObject1.isEqual(numObject1)  // true
      numObject1.isEqual(numObject2)  // true
      

      I expect all expression in the first code block to be true analogous to the second code block.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jaspa Janek Spaderna
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: