SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Not all transitive references are corrected by require_explicit_imports

Open kastiglione opened this issue 5 years ago • 3 comments

Describe the bug

We use require_explicit_imports: true, and have some found some cases where SwiftLint does not add imports for transitively used swift modules. The ones I've seen so far are:

  1. Use of functions defined on extensions, where the module that defines the extension is not directly imported by the module that references the extension
  2. Calling functions that have parameters with default values, and where the function/initializer of the default is defined in a module not directly imported
  3. References to type metadata from modules not directly referenced. For example, one case was self.mapView.rx.willMove, and the module that defines the type of willMove was not being directly imported (it may also be relevant that the type of willMove is a generic and it conformed to a protocol)

In these cases, if the import does exist, the unused_import rule will remove it, which prevents manual fixes.

The main purpose of this issue is to see if these have been discussed, and to see if these implicit references are visible from SourceKit. These cases were identified when switching to dynamic linking, instead of static linking.

kastiglione avatar May 16 '20 00:05 kastiglione

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

stale[bot] avatar Nov 08 '20 03:11 stale[bot]

Still relevant

keith avatar Nov 09 '20 19:11 keith

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

stale[bot] avatar Jan 08 '21 19:01 stale[bot]