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

nil converted to NSNull when returned from a nonnull Objective-C method

    XMLWordPrintable

    Details

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

      Xcode Version 9.2 (9C40b).

      Description

      If Swift code receives nil from a function declared in Objective-C which is marked as returning nonull, and the return value of that function is passed into an Objective-C function, that function will receive an instance of NSNull instead of nil, regardless of whether that function's parameter is annotated nonnull or nullable. In other words:

      {{ let liar = Liar() // Implemented in Objective-C}}
      {{ let obj = liar.totallyNotNull() // returns nil}}
      {{ liar.takeNonNull(obj) // receives NSNull}}
      {{ liar.takeNull(obj) // receives NSNull}}

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              benpious Ben Pious
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: