Skip to content

Commit 6f82991

Browse files
committed
wire up config-driven generic specialization
Configuration.specialize was fully defined (JSON schema, SpecializationConfigEntry, SwiftAnalyzer.registerSpecialization) but nothing in the actual jextract run ever read it - translator.analyze() was called with no hook, so a "specialize": {...} block in swift-java.config silently did nothing. Pass a hook that registers each entry via registerSpecialization before deferred constrained extensions are processed, so config-declared specializations of a generic type (e.g. Snowflake<Tag> -> GuildSnowflake, ChannelSnowflake, ...) actually produce usable per-instantiation Java classes.
1 parent 5d3f0c1 commit 6f82991

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎Sources/JExtractSwiftLib/Swift2Java.swift‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,20 @@ public struct SwiftToJava {
119119
translator.sourceDependencies.loadSwiftSources(from: config, log: translator.log)
120120
}
121121

122-
try translator.analyze()
122+
try translator.analyze { analyzer in
123+
for (outputName, entry) in config.specialize ?? [:] {
124+
guard
125+
analyzer.registerSpecialization(
126+
baseQualifiedName: entry.base,
127+
outputName: outputName,
128+
typeArgs: entry.typeArgs
129+
) != nil
130+
else {
131+
log.warning("Failed to register configured specialization '\(outputName)' of '\(entry.base)'")
132+
continue
133+
}
134+
}
135+
}
123136

124137
switch config.effectiveMode {
125138
case .ffm:

0 commit comments

Comments
 (0)