Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftExtract/SwiftAnalysisVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ final class SwiftAnalysisVisitor {
in typeContext: ExtractedNominalType?,
sourceFilePath: String,
) {
guard node.shouldExtract(config: config, in: typeContext, decider: analyzer.extractDecider) else {
return
}

let outputName = node.name.text
let rhsType = node.initializer.value

Expand Down
30 changes: 30 additions & 0 deletions Tests/SwiftExtractTests/AnalysisResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

import SwiftExtract
import SwiftSyntax
import Testing

/// End-to-end tests that drive the analysis pipeline (Swift source →
Expand Down Expand Up @@ -553,6 +554,35 @@ struct AnalysisResultSuite {
#expect(fishTank.isSpecialization)
}

@Test func typealiasTriggersDecider() throws {
final class RecordingDecider: ExtractDecider, @unchecked Sendable {
var typealiasNames: [String] = []
func shouldExtract(decl: DeclSyntax, in parent: ExtractedNominalType?) -> Bool {
if let ta = decl.as(TypeAliasDeclSyntax.self) {
typealiasNames.append(ta.name.text)
}
return true
}
}
let decider = RecordingDecider()
_ = try SwiftAnalyzer.analyze(
sources: [
(
"/fake/Source.swift",
"""
public struct Tank<Element> { public init() {} }
public struct Fish {}
public typealias FishTank = Tank<Fish>
"""
)
],
moduleName: "Aquarium",
extractDecider: decider,
config: DefaultSwiftExtractConfiguration(swiftModule: "Aquarium")
)
#expect(decider.typealiasNames == ["FishTank"])
}

// ==== -----------------------------------------------------------------------
// MARK: Empty input

Expand Down
Loading