// @ts-check // B inlines A's @inline function, and is // compiled again when that body changes although A's interface does not. import * as assert from "node:assert"; import * as fs from "node:fs/promises"; import * as path from "node:path"; import { setup } from "#dev/process"; const { execBuildOrThrow, execClean } = setup(import.meta.dirname); const source = path.join(import.meta.dirname, "src", "A.res"); const output = path.join(import.meta.dirname, "src", "B.mjs"); const original = await fs.readFile(source, "utf8"); await execClean(); try { await execBuildOrThrow(); assert.match(await fs.readFile(output, "utf8"), /let result = 2;/); // Same line, same type: only A's .cmj changes. await fs.writeFile(source, original.replace("x + 1", "x + 2")); await execBuildOrThrow(); assert.match(await fs.readFile(output, "utf8"), /let result = 3;/); // Without @inline, B calls the function. await fs.writeFile(source, original.replace("@inline\n", "")); await execBuildOrThrow(); assert.match(await fs.readFile(output, "utf8"), /A\.bump\(1\)/); } finally { await fs.writeFile(source, original); await execClean(); }