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

Decoding typedef NSString

    XMLWordPrintable

    Details

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

      Xcode 9.3 beta 3 (9Q117m)

      Description

      The struct imported from the Objective-C the code:

      typedef NSString *Foo NS_TYPED_EXTENSIBLE_ENUM;
      Foo const BarKey;
      

      After import to Swift the `Foo` type is not Codable. It wasn't enforced in Swift 4.0, but it is in Swift 4.1

      This can't be used with decoder (implementing 

          public typealias RawValue = [Foo: Any]
      
          public init(from decoder: Decoder) throws {
              var unkeyedContainer = try decoder.unkeyedContainer()
              self.init(rawValue: try unkeyedContainer.decode(RawValue.self))!
          }
      
      // error: type 'Foo' does not conform to protocol 'Encodable'
      

      this code worked in Swift 4.0.3. Either it didn't work properly in Swift 4.0, or it isn't possible to import Foo as Codable. I'm feel confused.

        Attachments

          Activity

            People

            • Assignee:
              itaiferber Itai Ferber
              Reporter:
              krzyzanowskim Marcin Krzyzanowski
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: