Skip to content

Commit 36d18c1

Browse files
committed
Merge current main and document expected-red TypeScript case
Signed-off-by: mikemikimike <13286568797@163.com>
2 parents 268a9d8 + e032a8e commit 36d18c1

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎tests/repro/repro_lsp_ts.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,32 @@ static const RFile kTsImport[] = {
297297
"function caller(v: number): number { return helper(v); }\n"},
298298
};
299299

300+
/* An imported class constructed through an inferred local variable must retain
301+
* the imported class QN for subsequent member dispatch. The explicit type
302+
* annotation path already covers this shape; this fixture isolates inference.
303+
*/
304+
static const RFile kTsInferredImportedMethod[] = {
305+
{"store.ts",
306+
"export class WidgetStore {\n"
307+
" findById(id: string): string { return id; }\n"
308+
"}\n"},
309+
{"service.ts",
310+
"import { WidgetStore } from \"./store\";\n"
311+
"function load(id: string): string {\n"
312+
" const store = new WidgetStore();\n"
313+
" return store.findById(id);\n"
314+
"}\n"},
315+
};
316+
317+
/* A standard-library class constructed through an inferred local variable must
318+
* retain its bare stdlib QN for member dispatch; the current expected-red
319+
* result and investigation are documented at the board case below. */
320+
static const char kTsInferredStdlibMethod[] =
321+
"function lookup(id: string): string {\n"
322+
" const m = new Map<string, string>();\n"
323+
" return m.get(id);\n"
324+
"}\n";
325+
300326
/* lsp_ts_jsx — <Comp/> JSX element whose tag is a module-local component
301327
* function (ts_lsp.c:2643-2647). TSX only (jsx_mode); the tag's first letter is
302328
* uppercase so it is NOT treated as an intrinsic HTML element; it resolves via
@@ -370,6 +396,24 @@ TEST(repro_lsp_ts_import) {
370396
"lsp_ts_import");
371397
}
372398

399+
TEST(repro_lsp_ts_inferred_import_receiver) {
400+
return assert_lsp_strategy_files(
401+
kTsInferredImportedMethod,
402+
(int)(sizeof(kTsInferredImportedMethod) /
403+
sizeof(kTsInferredImportedMethod[0])),
404+
"lsp_ts_method");
405+
}
406+
407+
TEST(repro_lsp_ts_inferred_stdlib_receiver) {
408+
/* EXPECTED-RED on the non-gating board: the runner emits no callable-
409+
* sourced CALLS edge (callable=0) and no lsp_ts_method strategy. Verified
410+
* with scripts/repro.sh CC=gcc CXX=g++; the focused ts_lsp suite does not
411+
* run this file. Current, unproven hypothesis: Map.get is unavailable as
412+
* a callable target from the TypeScript stdlib seed. */
413+
return assert_lsp_strategy("main.ts", kTsInferredStdlibMethod,
414+
"lsp_ts_method");
415+
}
416+
373417
TEST(repro_lsp_ts_jsx) {
374418
return assert_lsp_strategy("app.tsx", kTsxJsx, "lsp_ts_jsx");
375419
}
@@ -403,6 +447,8 @@ SUITE(repro_lsp_ts) {
403447
RUN_TEST(repro_lsp_ts_method);
404448
RUN_TEST(repro_lsp_ts_namespace);
405449
RUN_TEST(repro_lsp_ts_import);
450+
RUN_TEST(repro_lsp_ts_inferred_import_receiver);
451+
RUN_TEST(repro_lsp_ts_inferred_stdlib_receiver);
406452
RUN_TEST(repro_lsp_ts_jsx);
407453
RUN_TEST(repro_lsp_ts_jsx_import);
408454
RUN_TEST(repro_lsp_ts_default);

0 commit comments

Comments
 (0)