periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Unused import false-positive for module that provides a conformance

Open ileitch opened this issue 1 year ago • 0 comments

When a file does not reference any declarations in a given module, but that module does provide a conformance that is required in the file, the import removal can result in a build failure. For example:

A/a.swift:

class Foo {}

B/b.swift:

import A

extension Foo: SomeProtocol {
  var someProperty: Int
}

C/c.swift:

import B

func someMethod(_ thing: SomeProtocol) {}

D/d.swift:

import A
import B // unused, yet required because it conforms Foo to SomeProtocol
import C

someMethod(Foo())

ileitch avatar Aug 23 '24 22:08 ileitch