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-4389] Extending generic nested type in separate files fails #46968

Closed
ffried opened this issue Mar 28, 2017 · 3 comments
Closed

[SR-4389] Extending generic nested type in separate files fails #46968

ffried opened this issue Mar 28, 2017 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@ffried
Copy link
Contributor

ffried commented Mar 28, 2017

Previous ID SR-4389
Radar None
Original Reporter @ffried
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 3.1 (swiftlang-802.0.48 clang-802.0.38)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 42a378d04d904542f3c68d7e566ba2b2

duplicates:

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

relates to:

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

Issue Description:

Extending a generic nested type in a separate file fails with an error stating that the nested type isn't a member of the type it is nested in.

Example

Given the following two files:

genericSubtypesBase.swift

public struct BaseType {}

public extension BaseType {
    public struct SubType<T> {}
}

genericSubtypesExtension.swift

public extension BaseType.SubType {}

compiling them with swiftc -v genericSubtypesExtension.swift genericSubtypesBase.swift gives the following output:

Apple Swift version 3.1 (swiftlang-802.0.48 clang-802.0.38)
Target: x86_64-apple-macosx10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file genericSubtypesExtension.swift genericSubtypesBase.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name main -o /var/folders/0z/101fmx1n5hl3g6l0vrn5g9qh0000gn/T/genericSubtypesExtension-14e4ba.o
genericSubtypesExtension.swift:1:27: error: 'SubType' is not a member type of 'BaseType'
public extension BaseType.SubType {}

Note
This error can also be reproduced by adding the two files to a new Framework Project in Xcode and hit Build.

@belkadan
Copy link
Contributor

Probably the same as SR-631, but the "generic" might be an extra wrinkle.

@ffried
Copy link
Contributor Author

ffried commented Mar 29, 2017

At least the workaround (to move the file defining BaseType and SubType before the one extending SubType) works in this case as well.

@slavapestov
Copy link
Member

It's the same 😉

@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
Projects
None yet
Development

No branches or pull requests

3 participants