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

Decodable conformance of classes in different files yields bogus "Class ... has no initializers" error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
    • Environment:

      Swift version 4.2-dev (LLVM 95345677bd, Clang daefc772c1, Swift 76c264e9a1)
      Target: x86_64-apple-darwin17.4.0

      Description

      The following Swift files fail to compile:

      a.swift
      class C1 : Decodable { // error: Class 'C1' has no initializers
        let str: String
      }
      
      b.swift
      class C : Decodable {
        let c1: C1
      }
      

      But they really should as we should be synthesising an init(from:) for C1. Note that the above example does compile with whole module optimisation enabled if the file a.swift comes before b.swift.

        Attachments

          Activity

            People

            • Assignee:
              slavapestov Slava Pestov
              Reporter:
              originaluser2 Hamish Knight
            • Votes:
              18 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: