diff --git a/Sources/PeripheryKit/SourceGraph/Mutators/EncodablePropertyRetainer.swift b/Sources/PeripheryKit/SourceGraph/Mutators/EncodablePropertyRetainer.swift index c1ead2159..0408b6835 100644 --- a/Sources/PeripheryKit/SourceGraph/Mutators/EncodablePropertyRetainer.swift +++ b/Sources/PeripheryKit/SourceGraph/Mutators/EncodablePropertyRetainer.swift @@ -7,12 +7,10 @@ import Shared /// assume that all properties are in use, as they may be referenced by synthesized code. final class EncodablePropertyRetainer: SourceGraphMutator { private let graph: SourceGraph - private let configuration: Configuration private let externalCodableProtocols: [String] required init(graph: SourceGraph, configuration: Configuration) { self.graph = graph - self.configuration = configuration self.externalCodableProtocols = configuration.externalEncodableProtocols + configuration.externalCodableProtocols } diff --git a/Tests/Fixtures/RetentionFixtures/testRetainsInitializerCalledOnTypeAlias.swift b/Tests/Fixtures/RetentionFixtures/testRetainsInitializerCalledOnTypeAlias.swift new file mode 100644 index 000000000..d42a60043 --- /dev/null +++ b/Tests/Fixtures/RetentionFixtures/testRetainsInitializerCalledOnTypeAlias.swift @@ -0,0 +1,11 @@ +class FixtureClass219 { + init(foo: Int) {} +} + +public class FixtureClass219Retainer { + typealias FixtureClass219Aliased = FixtureClass219 + + public func retain() { + _ = Self.FixtureClass219Aliased(foo: 1) + } +} diff --git a/Tests/PeripheryTests/RetentionTest.swift b/Tests/PeripheryTests/RetentionTest.swift index 8e9c53abd..9a8fd3d97 100644 --- a/Tests/PeripheryTests/RetentionTest.swift +++ b/Tests/PeripheryTests/RetentionTest.swift @@ -1564,4 +1564,15 @@ final class RetentionTest: FixtureSourceGraphTestCase { } } } + + // https://github.com/peripheryapp/periphery/issues/676 + func testRetainsInitializerCalledOnTypeAlias() { + guard performKnownFailures else { return } + + analyze(retainPublic: true) { + assertReferenced(.class("FixtureClass219")) { + self.assertReferenced(.functionConstructor("init(foo:)")) + } + } + } }