Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4568] Extension of a nested type defined in a separate source file fails to compile #47145

Closed
swift-ci opened this issue Apr 12, 2017 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-4568
Radar None
Original Reporter memoto (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment
  • macOS Sierra 10.12.4 (16E195)

  • Xcode 8.3.1 (8E1000a)

  • Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41)
    Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: fd382991533b26beb2b81391e4587b9c

duplicates:

  • SR-631 Extensions in different files do not recognize each other

Issue Description:

Problem:

The example below compiles fine only in case of the right source files order

Workaround:

In Xcode: Build Phases -> Compile Sources:
Make sure the source with nested type we gonna extend (Zoo.swift) is above the extension contained source (Zoo+CageSize.swift)

Generated error message:

 'Cage' is not a member type of 'Zoo'
extension Zoo.Cage {
          ~~~ ^

Sources:

// Zoo.swift
struct Zoo {
   let cages: [Cage]
}

extension Zoo {
    struct Cage {
         // ...
    }
}
// Zoo+CageSize.swift
extension Zoo.Cage {
   enum Size {
      case standard
      case large
      case small
   }
}
@swift-ci
Copy link
Collaborator Author

Comment by Denis Kirillov (JIRA)

I confirm the same problem.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 5, 2018

Comment by Tom Stoffer (JIRA)

This can be worked around by moving files around in the "Compile Sources" section in Build Phases in Xcode. However I'm not sure if this is possible when compiling with podspecs. Anyone know how?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant