( expr: string, scope: BaseScope, shadowed?: ReadonlySet<string> )
| 1349 | } |
| 1350 | |
| 1351 | const checkStringGenericDrops = ( |
| 1352 | expr: string, |
| 1353 | scope: BaseScope, |
| 1354 | shadowed?: ReadonlySet<string> |
| 1355 | ): { op: DroppedNarrowOp; operand: string }[] => { |
| 1356 | const drops: { op: DroppedNarrowOp; operand: string }[] = [] |
| 1357 | for (const call of scanStringGenerics(expr)) { |
| 1358 | const target = lookupInScope(call.name, scope, shadowed) |
| 1359 | if (!hasArkKind(target, "generic")) continue |
| 1360 | const info = structuralGenericOf(target) |
| 1361 | if (!info) continue |
| 1362 | const [op, argIndices] = info |
| 1363 | if (call.args.length !== target.params.length) continue |
| 1364 | const argRoots: BaseRoot[] = [] |
| 1365 | let allResolved = true |
| 1366 | for (const arg of call.args) { |
| 1367 | const r = evalStringTypeInScope(arg, scope, new Set(), shadowed) |
| 1368 | if (!r) { |
| 1369 | allResolved = false |
| 1370 | break |
| 1371 | } |
| 1372 | argRoots.push(r) |
| 1373 | } |
| 1374 | if (!allResolved) continue |
| 1375 | const after = applyStructuralOp(op, argRoots) |
| 1376 | if (!after) continue |
| 1377 | for (const idx of argIndices) { |
| 1378 | if (dropsUserPredicate(argRoots[idx], after)) |
| 1379 | drops.push({ op, operand: call.args[idx] }) |
| 1380 | } |
| 1381 | } |
| 1382 | return drops |
| 1383 | } |
| 1384 | |
| 1385 | export const isDropNarrowSuppressed = ( |
| 1386 | module: SourceModule, |
no test coverage detected