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

`Mirror` fails to reflect enums that have a single-case enum as their associated values.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Standard Library
    • Labels:
    • Environment:

      Playground
      Swift 4.2, Xcode 10.1
      Swift 5.0, Xcode 10.2

      Description

      If the inner enum type has more than one case, `Mirror` can reflect without issue.
      But if the inner enum type has just one case, `Mirror` returns no children at all.

      Code snippet:

      enum Inner {
          case hello
      //    case no
      }
      
      enum Outer {
          case inner(Inner)
      }
      
      print(
          Mirror(reflecting: Outer.inner(.hello)).children.map { $0 }
      )
      // Print `[]` when `Inner` has only `hello`.
      // Print `[(label: Optional("inner"), value: __lldb_expr_1.Inner.hello)]` when `Inner` has both `hello` and `no`.
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            andersha Anders Ha
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: