Xcode/Swift can't figure out what to do with type defined within a conditional extension block

Continuing the discussion from How can I fix "Type 'MyType' does not conform to protocol 'Collection'"?:

From the thread above, it seems if you:

  • Make a type conform to a protocol
  • Conditionally conform it to another protocol, where the second protocol:
    • Refines the first
    • Adds associated types that the first one didn't have
  • Define an associated type within a conditionally active extension block of the type

Then the compiler (or Xcode) gets fried figuring out the existence of the type, let alone using its existence to check if the type actually (conditionally) conforms. The second protocol's conditional attachment can be in a separate extension block from the conditional type. A (definitive) externally defined associated type imported through a type-alias is OK. I don't know if an also-conditional externally defined associated type triggers the problem, or even if it would get past its owning types problems with this bug. I don't know if an unconditional nested type used as a conditional protocol's associated type works or not.

Has anyone seen this bug before?

Terms of Service

Privacy Policy

Cookie Policy