Skip to content

Conversation

@QuietMisdreavus
Copy link
Contributor

Resolves rdar://98808363, fixes #60771

This PR fixes a handful of rough edges surrounding re-exported modules, extensions, and Clang symbols:

  1. Re-exporting a module doesn't include that module's Clang symbols.
  2. If a module renames a Clang symbol in Swift via API notes, children of that symbol can be incorrectly sorted into an extension graph.
  3. Tertiary chains of extensions and module re-exports can incorrectly sort the third- and lower-level symbols into the main graph instead of an extension.

These issues primarily occur when a module re-exports Foundation, but the patterns can be recreated outside of Foundation.

… extensions

consider this scenario:

- module A
  - struct BaseStruct
- module B
  - struct BaseStruct.InnerStruct
  - func BaseStruct.InnerStruct.doStuff()
- module C
  - `@_exported import B`

the current export-import code effectively short-circuits if the direct
parent of a symbol is from a re-exported module. however, that symbol
could itself be another extension, so the check needs to recurse
_first_, to catch this scenario. before this change,
`BaseStruct.InnerStruct.doStuff()` would be sorted into C's main module
graph, but `BaseStruct.InnerStruct` would be sorted into `C@A` instead,
creating an orphan symbol.
@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/ExportedImport/ObjcProperty.framework %t
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module -o %t/ObjcProperty.framework/Modules/ObjcProperty.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name ObjcProperty %S/Inputs/ExportedImport/A.swift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth also having a separate test for swift-symbolgraph-extract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swift-symbolgraph-extract doesn't have support for processing re-exports (#59920) so any tests i add for that will just confirm that the symbols don't exist.

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.

"Symbol with identifier 's:So9NSDecimala10FoundationE11FormatStyleV8CurrencyV' couldn't be found" error

3 participants