@@ -398,9 +398,20 @@ typedef struct {
398398 const char * member ; // ES named import: the exported name the local binds (`get` in
399399 // `import { get as navigate } from "axios"`); NULL otherwise
400400 bool is_default ; // ES default import (`import X from "Y"`), JS/TS only (#1916)
401+ bool type_checking_only ; // Python: inside a module-level `if TYPE_CHECKING:` block --
402+ // binds the name for annotations, never at runtime (#1277)
401403 CBMImportKind kind ; // CBM_IMPORT_KIND_DEFAULT unless the syntax names a member kind
402404} CBMImport ;
403405
406+ /* True when an import binds its local name at runtime. A Python import under
407+ * `if TYPE_CHECKING:` exists for annotations only: a call through that name
408+ * cannot happen, so no CALLS import map may bind it (an import_map edge
409+ * through it would be fabricated by construction). THE one rule every CALLS
410+ * import-map builder applies. */
411+ static inline bool cbm_import_binds_runtime_name (const CBMImport * imp ) {
412+ return imp && !imp -> type_checking_only ;
413+ }
414+
404415/* Content-only ordered Python namespace facts; no resolved target identities. */
405416#define CBM_PY_NAMESPACE_FACTS_VERSION 1u
406417
@@ -1306,6 +1317,14 @@ void cbm_py_namespace_test_copy_fail_after(int successful_allocations);
13061317void cbm_defs_push (CBMDefArray * arr , CBMArena * a , CBMDefinition def );
13071318void cbm_calls_push (CBMCallArray * arr , CBMArena * a , CBMCall call );
13081319void cbm_imports_push (CBMImportArray * arr , CBMArena * a , CBMImport imp );
1320+ /* True unless every import of `imports` that binds `local_name` is
1321+ * annotation-only (cbm_import_binds_runtime_name), so also true when no import
1322+ * names it: the rule for the builders that key IMPORTS edges by local name. */
1323+ bool cbm_imports_local_binds_runtime_name (const CBMImportArray * imports , const char * local_name );
1324+ /* The same for the `len` bytes at `name` (not NUL-terminated): lets a caller
1325+ * decide before it copies the name. */
1326+ bool cbm_imports_local_span_binds_runtime_name (const CBMImportArray * imports , const char * name ,
1327+ size_t len );
13091328void cbm_usages_push (CBMUsageArray * arr , CBMArena * a , CBMUsage usage );
13101329void cbm_throws_push (CBMThrowArray * arr , CBMArena * a , CBMThrow thr );
13111330void cbm_rw_push (CBMRWArray * arr , CBMArena * a , CBMReadWrite rw );
0 commit comments