diff --git a/gitnexus/src/core/ingestion/import-processor.ts b/gitnexus/src/core/ingestion/import-processor.ts index e4753ef9e..2e2816a7d 100644 --- a/gitnexus/src/core/ingestion/import-processor.ts +++ b/gitnexus/src/core/ingestion/import-processor.ts @@ -143,15 +143,17 @@ function groupSwiftFilesByTarget( * Swift has no file-level imports — all files in a module see each other. */ function addSwiftImplicitImports( - files: { path: string }[], + files: string[] | { path: string }[], swiftPackageConfig: SwiftPackageConfig | null, importMap: Map>, addImportEdge: (src: string, target: string) => void, logSuffix = '', ): void { - const swiftFiles = files - .filter(f => getLanguageFromFilename(f.path) === SupportedLanguages.Swift) - .map(f => f.path); + const paths = typeof files[0] === 'string' + ? files as string[] + : (files as { path: string }[]).map(f => f.path); + const swiftFiles = paths + .filter(f => getLanguageFromFilename(f) === SupportedLanguages.Swift); if (swiftFiles.length <= 1) return; @@ -382,7 +384,7 @@ export const processImports = async ( // Tree is now owned by the LRU cache — no manual delete needed } - addSwiftImplicitImports(allFileList.map(p => ({ path: p })), configs.swiftPackageConfig, importMap, addImportEdge); + addSwiftImplicitImports(allFileList, configs.swiftPackageConfig, importMap, addImportEdge); if (skippedByLang && skippedByLang.size > 0) { for (const [lang, count] of skippedByLang.entries()) { diff --git a/gitnexus/src/core/ingestion/type-env.ts b/gitnexus/src/core/ingestion/type-env.ts index baec16881..7e24bc0c4 100644 --- a/gitnexus/src/core/ingestion/type-env.ts +++ b/gitnexus/src/core/ingestion/type-env.ts @@ -872,9 +872,7 @@ export const buildTypeEnv = ( ?? node.childForFieldName('left') ?? node.childForFieldName('pattern'); if (nameNode) { - // Swift: pattern node wraps a simple_identifier — unwrap it - const varName = extractVarName(nameNode) - ?? (nameNode.type === 'pattern' ? extractVarName(nameNode.firstNamedChild!) ?? nameNode.text : undefined); + const varName = extractVarName(nameNode); if (varName && !declarationTypeNodes.has(`${scope}\0${varName}`)) { declarationTypeNodes.set(`${scope}\0${varName}`, typeNode); } diff --git a/gitnexus/src/core/ingestion/type-extractors/shared.ts b/gitnexus/src/core/ingestion/type-extractors/shared.ts index ff402adce..d767e6f3f 100644 --- a/gitnexus/src/core/ingestion/type-extractors/shared.ts +++ b/gitnexus/src/core/ingestion/type-extractors/shared.ts @@ -317,6 +317,11 @@ export const extractVarName = (node: SyntaxNode): string | undefined => { const inner = node.firstNamedChild; if (inner) return extractVarName(inner); } + // Swift: pattern node wraps a simple_identifier + if (node.type === 'pattern') { + const inner = node.firstNamedChild; + if (inner) return extractVarName(inner); + } return undefined; }; diff --git a/gitnexus/test/integration/resolvers/swift.test.ts b/gitnexus/test/integration/resolvers/swift.test.ts index 32c912ea7..e773ce56e 100644 --- a/gitnexus/test/integration/resolvers/swift.test.ts +++ b/gitnexus/test/integration/resolvers/swift.test.ts @@ -467,12 +467,6 @@ describe.skipIf(!swiftAvailable)('Swift await / try expression unwrapping', () = }); }); -// --------------------------------------------------------------------------- -// for-in loop element type inference: -// extractForLoopBinding derives element type from the iterable's declared -// type annotation (e.g., [User] → User). -// --------------------------------------------------------------------------- - // --------------------------------------------------------------------------- // For-in loop element type inference: extractForLoopBinding derives element // type from the iterable's declared type annotation (e.g., [User] → User).