Skip to content

Fix a crash when a protocol with a default implementation is aliased with the same name #534

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

Merged

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: rdar://107623749

Summary

Fix a crash (from a fatalError in DocumentationContext) when a protocol with a default implementation in one module is both @_export imported and type aliased in another module.

Dependencies

None

Testing

  • Create a project two targets—for example named "Outer" and "Inner"—where one target depend on the other
  • In the "Inner" target, define a protocol with some requirement and provide a default implementation for that requirement
    // Inner.swift
     public protocol Something {
         func doSomething()
     }
     public extension Something {
         func doSomething() {}
     }
    
  • In the "Outer" target, use @_exported import to bring the symbols of the "Inner" target into the "Outer" target and also create a typealias with the same name as protocol from the "Inner" target
    // Outer.swift
    @_exported import Inner
    public typealias Something = Inner.Something
    
  • Build documentation for the outer target. This shouldn't crash. Both the protocol requirement and the default implementation should exist under the Something protocol in the Outer target's documentation—like they do in the Inner target's documentation.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist requested a review from franklinsch April 6, 2023 01:39
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit c856d7a into swiftlang:main Apr 6, 2023
@d-ronnqvist d-ronnqvist deleted the default-impl-exported-import-crash branch April 6, 2023 15:41
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Apr 6, 2023
…with the same name (swiftlang#534)

* Fix crash when exported import protocol is aliased with same name

rdar://107623749

* Remove incorrect memberOf relationships in handcrafted test symbol data
d-ronnqvist added a commit that referenced this pull request Apr 11, 2023
…with the same name (#534) (#536)

* Fix crash when exported import protocol is aliased with same name

rdar://107623749

* Remove incorrect memberOf relationships in handcrafted test symbol data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants