From af7a215dd7f4fbf5e2361dbe2324cd670cdd53c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Tue, 6 Oct 2026 00:00:05 +0200 Subject: [PATCH] fix(class): keep specialization IDs unique across modules --- changelog.d/PENDING-recur2-class-ids.md | 3 + crates/perry-hir/src/lib.rs | 2 +- crates/perry-hir/src/monomorph/context.rs | 2 +- crates/perry-hir/src/monomorph/driver.rs | 30 +- crates/perry-hir/src/monomorph/mod.rs | 2 +- crates/perry-hir/src/monomorph/tests.rs | 109 +- .../perry/src/commands/compile/bootstrap.rs | 15 +- .../_helpers/recur_class_id_literals.ts | 1102 +++++++++++++++++ test-files/test_gap_recur_class_id_unique.ts | 18 + 9 files changed, 1233 insertions(+), 50 deletions(-) create mode 100644 changelog.d/PENDING-recur2-class-ids.md create mode 100644 test-files/_helpers/recur_class_id_literals.ts create mode 100644 test-files/test_gap_recur_class_id_unique.ts diff --git a/changelog.d/PENDING-recur2-class-ids.md b/changelog.d/PENDING-recur2-class-ids.md new file mode 100644 index 0000000000..9ba512cebd --- /dev/null +++ b/changelog.d/PENDING-recur2-class-ids.md @@ -0,0 +1,3 @@ +Generic class specializations now allocate class IDs from one sequence above all declared classes and object-literal shapes in the program. The old per-module maximum plus 1,000 could reuse another module's literal ID, making a class instance's shape claim the default `Object.prototype` edge. This preserves the shape-based prototype fast path while restoring the declared class prototype and inherited methods on descriptor clones, including Effect 4 Schema initialization. + +Adds a multi-module gap regression with 1,100 distinct literal shapes and a HIR unit test covering specialization IDs and origin metadata across modules. The regression first became observable in `993bcb2e9704bf9596cc1710c8373060b4372cab` (PR #12024); its parent `8ec553a709` matches Node. diff --git a/crates/perry-hir/src/lib.rs b/crates/perry-hir/src/lib.rs index 84d71b177e..f810168048 100644 --- a/crates/perry-hir/src/lib.rs +++ b/crates/perry-hir/src/lib.rs @@ -71,7 +71,7 @@ pub use lower::{ lower_module_with_class_id, lower_module_with_class_id_and_types, lower_module_with_class_id_types_and_seed, lower_module_with_class_id_types_seed_and_entry, }; -pub use monomorph::monomorphize_module; +pub use monomorph::{monomorphize_module, monomorphize_modules}; pub use native_profile::exported_native_pod_abi; pub use patched_builtins::{ clear_patched_builtins, patched_prototype_methods, scan_module as scan_patched_builtins, diff --git a/crates/perry-hir/src/monomorph/context.rs b/crates/perry-hir/src/monomorph/context.rs index f8f41ef451..64b4320e00 100644 --- a/crates/perry-hir/src/monomorph/context.rs +++ b/crates/perry-hir/src/monomorph/context.rs @@ -106,7 +106,7 @@ impl MonomorphizationContext { func_work_queue: VecDeque::new(), class_work_queue: VecDeque::new(), next_func_id: max_func_id + 1000, // Leave room for original IDs - next_class_id: max_class_id + 1000, + next_class_id: max_class_id + 1, processed_funcs: HashSet::new(), processed_classes: HashSet::new(), } diff --git a/crates/perry-hir/src/monomorph/driver.rs b/crates/perry-hir/src/monomorph/driver.rs index b6601bb6a4..0158ddc06d 100644 --- a/crates/perry-hir/src/monomorph/driver.rs +++ b/crates/perry-hir/src/monomorph/driver.rs @@ -3,11 +3,35 @@ use super::*; /// Main monomorphization pass /// Processes the module and generates specialized versions of generic functions/classes pub fn monomorphize_module(module: &mut Module) { - let mut ctx = MonomorphizationContext::new(module); + monomorphize_modules(std::iter::once(module)); +} + +/// Specialize a program's modules using one class-ID allocation sequence. +/// Lowering has already assigned IDs to declared classes and literal shapes; +/// every specialization must be above that whole program's range, not just +/// above the classes in its own module. +pub fn monomorphize_modules<'a>(modules: impl IntoIterator) { + let modules: Vec<_> = modules.into_iter().collect(); + let mut next_class_id = modules + .iter() + .flat_map(|module| &module.classes) + .map(|class| class.id) + .max() + .unwrap_or(0) + + 1; + for module in modules { + let mut ctx = MonomorphizationContext::new(module); + ctx.next_class_id = next_class_id; + monomorphize_with_context(module, &mut ctx); + next_class_id = ctx.next_class_id; + } +} + +fn monomorphize_with_context(module: &mut Module, ctx: &mut MonomorphizationContext) { let idx = ModuleIndex::new(module); // First pass: collect all generic instantiations from the code - collect_instantiations(module, &mut ctx, &idx); + collect_instantiations(module, ctx, &idx); // Process work queues until empty let mut new_functions = Vec::new(); @@ -116,7 +140,7 @@ pub fn monomorphize_module(module: &mut Module) { } // Update call sites to use specialized versions - update_call_sites(module, &ctx); + update_call_sites(module, ctx); // Fill in default arguments for constructor calls fill_default_arguments(module); diff --git a/crates/perry-hir/src/monomorph/mod.rs b/crates/perry-hir/src/monomorph/mod.rs index 9dead6cfad..503de18e3a 100644 --- a/crates/perry-hir/src/monomorph/mod.rs +++ b/crates/perry-hir/src/monomorph/mod.rs @@ -34,7 +34,7 @@ mod tests; pub use constraints::ConstraintError; pub use context::MonomorphizationContext; -pub use driver::monomorphize_module; +pub use driver::{monomorphize_module, monomorphize_modules}; pub use specialize::{specialize_class, specialize_function}; pub use substitute_type::substitute_type; diff --git a/crates/perry-hir/src/monomorph/tests.rs b/crates/perry-hir/src/monomorph/tests.rs index a405c7ea5b..7c48b555d8 100644 --- a/crates/perry-hir/src/monomorph/tests.rs +++ b/crates/perry-hir/src/monomorph/tests.rs @@ -948,39 +948,6 @@ fn assert_specialized_call(expr: &Expr, module: &Module, expected_name: &str) { /// red for days (#5960). This runs on every PR. #[test] fn a_specialized_class_reports_the_generics_display_name() { - fn generic_class(id: u32, name: &str) -> Class { - Class { - id, - name: name.to_string(), - type_params: vec![TypeParam { - name: "T".to_string(), - constraint: None, - default: None, - }], - extends: None, - extends_name: None, - native_extends: None, - extends_expr: None, - heritage_lexically_shadowed: false, - fields: vec![], - constructor: None, - methods: vec![], - getters: vec![], - setters: vec![], - static_accessor_names: vec![], - static_accessor_fn_ids: vec![], - static_fields: vec![], - static_methods: vec![], - computed_members: vec![], - decorators: vec![], - is_exported: false, - aliases: vec![], - is_nested: false, - alloc_width_hint: 0, - specialized_from: None, - } - } - let mut module = Module::new("test"); module.classes.push(generic_class(1, "Gen")); module.init.push(Stmt::Expr(Expr::New { @@ -1233,3 +1200,79 @@ fn fill_defaults_pads_before_appended_class_captures() { "the trailing capture args must be the captured values, not padding: {args:?}" ); } + +fn generic_class(id: u32, name: &str) -> Class { + Class { + id, + name: name.to_string(), + type_params: vec![TypeParam { + name: "T".to_string(), + constraint: None, + default: None, + }], + extends: None, + extends_name: None, + native_extends: None, + extends_expr: None, + heritage_lexically_shadowed: false, + fields: vec![], + constructor: None, + methods: vec![], + getters: vec![], + setters: vec![], + static_accessor_names: vec![], + static_accessor_fn_ids: vec![], + static_fields: vec![], + static_methods: vec![], + computed_members: vec![], + decorators: vec![], + is_exported: false, + aliases: vec![], + is_nested: false, + alloc_width_hint: 0, + specialized_from: None, + } +} + +#[test] +fn specializations_do_not_reuse_other_modules_class_or_literal_ids() { + let mut first = Module::new("first"); + first.classes.push(generic_class(1, "First")); + let mut second = Module::new("second"); + second.classes.push(generic_class(2, "Second")); + let mut literal = generic_class(1001, "Literal"); + literal.type_params.clear(); + second.classes.push(literal); + let mut third = Module::new("third"); + let mut last_literal = generic_class(1100, "LastLiteral"); + last_literal.type_params.clear(); + third.classes.push(last_literal); + + for (module, name) in [(&mut first, "First"), (&mut second, "Second")] { + for ty in [Type::Number, Type::String] { + module.init.push(Stmt::Expr(Expr::New { + class_name: name.to_string(), + args: vec![], + type_args: vec![ty], + byte_offset: 0, + cap_args_appended: 0, + })); + } + } + monomorphize_modules([&mut first, &mut second, &mut third]); + + let mut ids = HashSet::new(); + let mut specializations = 0; + for module in [&first, &second, &third] { + for class in &module.classes { + assert!(ids.insert(class.id), "duplicate class ID {}", class.id); + if let Some(origin) = &class.specialized_from { + specializations += 1; + assert!(class.id > 1100, "specialization overlaps lowered IDs"); + assert_eq!(module.class_display_names.get(&class.id), Some(origin)); + } + } + } + assert_eq!(specializations, 4); + assert_eq!(ids.len(), 8); +} diff --git a/crates/perry/src/commands/compile/bootstrap.rs b/crates/perry/src/commands/compile/bootstrap.rs index e053c486f4..25721cd21d 100644 --- a/crates/perry/src/commands/compile/bootstrap.rs +++ b/crates/perry/src/commands/compile/bootstrap.rs @@ -1073,16 +1073,9 @@ pub(super) fn run_native_instance_fixups(ctx: &mut CompilationContext) { } } - // Cross-module fix → local-fix re-run → monomorphize (parallel, - // fused per-module). Tier 4.2: pre-fix this was three separate - // `par_iter_mut().for_each(...)` passes. The local-fix re-run - // depends on `fix_cross_module_native_instances` having - // populated cross-module type info on this module, and - // monomorphize depends on the post-local-fix module shape — but - // both dependencies are intra-module, so running all three in - // one rayon job per module is safe and saves two scheduler - // round-trips. The cross-module step is gated on at least one - // export existing (skip the call entirely otherwise). + // Cross-module and local native-instance fixes remain module-local and + // parallel. Specialization below must share a class-ID allocator across + // the entire program, including every module's object-literal shapes. let has_native_exports = !exported_instances.is_empty() || !exported_func_return_instances.is_empty(); ctx.native_modules @@ -1101,8 +1094,8 @@ pub(super) fn run_native_instance_fixups(ctx: &mut CompilationContext) { // is false this is effectively a no-op since nothing changed // since the first local-fix in Pass A above. perry_hir::fix_local_native_instances(hir_module); - perry_hir::monomorphize_module(hir_module); }); + perry_hir::monomorphize_modules(ctx.native_modules.iter_mut().map(|(_, module)| module)); } /// --- HarmonyOS Phase 2: harvest perry/ui App({body: ...}) into ArkUI --- diff --git a/test-files/_helpers/recur_class_id_literals.ts b/test-files/_helpers/recur_class_id_literals.ts new file mode 100644 index 0000000000..3bec92a25d --- /dev/null +++ b/test-files/_helpers/recur_class_id_literals.ts @@ -0,0 +1,1102 @@ +export const literals = [ + { p0: 0 }, + { p1: 1 }, + { p2: 2 }, + { p3: 3 }, + { p4: 4 }, + { p5: 5 }, + { p6: 6 }, + { p7: 7 }, + { p8: 8 }, + { p9: 9 }, + { p10: 10 }, + { p11: 11 }, + { p12: 12 }, + { p13: 13 }, + { p14: 14 }, + { p15: 15 }, + { p16: 16 }, + { p17: 17 }, + { p18: 18 }, + { p19: 19 }, + { p20: 20 }, + { p21: 21 }, + { p22: 22 }, + { p23: 23 }, + { p24: 24 }, + { p25: 25 }, + { p26: 26 }, + { p27: 27 }, + { p28: 28 }, + { p29: 29 }, + { p30: 30 }, + { p31: 31 }, + { p32: 32 }, + { p33: 33 }, + { p34: 34 }, + { p35: 35 }, + { p36: 36 }, + { p37: 37 }, + { p38: 38 }, + { p39: 39 }, + { p40: 40 }, + { p41: 41 }, + { p42: 42 }, + { p43: 43 }, + { p44: 44 }, + { p45: 45 }, + { p46: 46 }, + { p47: 47 }, + { p48: 48 }, + { p49: 49 }, + { p50: 50 }, + { p51: 51 }, + { p52: 52 }, + { p53: 53 }, + { p54: 54 }, + { p55: 55 }, + { p56: 56 }, + { p57: 57 }, + { p58: 58 }, + { p59: 59 }, + { p60: 60 }, + { p61: 61 }, + { p62: 62 }, + { p63: 63 }, + { p64: 64 }, + { p65: 65 }, + { p66: 66 }, + { p67: 67 }, + { p68: 68 }, + { p69: 69 }, + { p70: 70 }, + { p71: 71 }, + { p72: 72 }, + { p73: 73 }, + { p74: 74 }, + { p75: 75 }, + { p76: 76 }, + { p77: 77 }, + { p78: 78 }, + { p79: 79 }, + { p80: 80 }, + { p81: 81 }, + { p82: 82 }, + { p83: 83 }, + { p84: 84 }, + { p85: 85 }, + { p86: 86 }, + { p87: 87 }, + { p88: 88 }, + { p89: 89 }, + { p90: 90 }, + { p91: 91 }, + { p92: 92 }, + { p93: 93 }, + { p94: 94 }, + { p95: 95 }, + { p96: 96 }, + { p97: 97 }, + { p98: 98 }, + { p99: 99 }, + { p100: 100 }, + { p101: 101 }, + { p102: 102 }, + { p103: 103 }, + { p104: 104 }, + { p105: 105 }, + { p106: 106 }, + { p107: 107 }, + { p108: 108 }, + { p109: 109 }, + { p110: 110 }, + { p111: 111 }, + { p112: 112 }, + { p113: 113 }, + { p114: 114 }, + { p115: 115 }, + { p116: 116 }, + { p117: 117 }, + { p118: 118 }, + { p119: 119 }, + { p120: 120 }, + { p121: 121 }, + { p122: 122 }, + { p123: 123 }, + { p124: 124 }, + { p125: 125 }, + { p126: 126 }, + { p127: 127 }, + { p128: 128 }, + { p129: 129 }, + { p130: 130 }, + { p131: 131 }, + { p132: 132 }, + { p133: 133 }, + { p134: 134 }, + { p135: 135 }, + { p136: 136 }, + { p137: 137 }, + { p138: 138 }, + { p139: 139 }, + { p140: 140 }, + { p141: 141 }, + { p142: 142 }, + { p143: 143 }, + { p144: 144 }, + { p145: 145 }, + { p146: 146 }, + { p147: 147 }, + { p148: 148 }, + { p149: 149 }, + { p150: 150 }, + { p151: 151 }, + { p152: 152 }, + { p153: 153 }, + { p154: 154 }, + { p155: 155 }, + { p156: 156 }, + { p157: 157 }, + { p158: 158 }, + { p159: 159 }, + { p160: 160 }, + { p161: 161 }, + { p162: 162 }, + { p163: 163 }, + { p164: 164 }, + { p165: 165 }, + { p166: 166 }, + { p167: 167 }, + { p168: 168 }, + { p169: 169 }, + { p170: 170 }, + { p171: 171 }, + { p172: 172 }, + { p173: 173 }, + { p174: 174 }, + { p175: 175 }, + { p176: 176 }, + { p177: 177 }, + { p178: 178 }, + { p179: 179 }, + { p180: 180 }, + { p181: 181 }, + { p182: 182 }, + { p183: 183 }, + { p184: 184 }, + { p185: 185 }, + { p186: 186 }, + { p187: 187 }, + { p188: 188 }, + { p189: 189 }, + { p190: 190 }, + { p191: 191 }, + { p192: 192 }, + { p193: 193 }, + { p194: 194 }, + { p195: 195 }, + { p196: 196 }, + { p197: 197 }, + { p198: 198 }, + { p199: 199 }, + { p200: 200 }, + { p201: 201 }, + { p202: 202 }, + { p203: 203 }, + { p204: 204 }, + { p205: 205 }, + { p206: 206 }, + { p207: 207 }, + { p208: 208 }, + { p209: 209 }, + { p210: 210 }, + { p211: 211 }, + { p212: 212 }, + { p213: 213 }, + { p214: 214 }, + { p215: 215 }, + { p216: 216 }, + { p217: 217 }, + { p218: 218 }, + { p219: 219 }, + { p220: 220 }, + { p221: 221 }, + { p222: 222 }, + { p223: 223 }, + { p224: 224 }, + { p225: 225 }, + { p226: 226 }, + { p227: 227 }, + { p228: 228 }, + { p229: 229 }, + { p230: 230 }, + { p231: 231 }, + { p232: 232 }, + { p233: 233 }, + { p234: 234 }, + { p235: 235 }, + { p236: 236 }, + { p237: 237 }, + { p238: 238 }, + { p239: 239 }, + { p240: 240 }, + { p241: 241 }, + { p242: 242 }, + { p243: 243 }, + { p244: 244 }, + { p245: 245 }, + { p246: 246 }, + { p247: 247 }, + { p248: 248 }, + { p249: 249 }, + { p250: 250 }, + { p251: 251 }, + { p252: 252 }, + { p253: 253 }, + { p254: 254 }, + { p255: 255 }, + { p256: 256 }, + { p257: 257 }, + { p258: 258 }, + { p259: 259 }, + { p260: 260 }, + { p261: 261 }, + { p262: 262 }, + { p263: 263 }, + { p264: 264 }, + { p265: 265 }, + { p266: 266 }, + { p267: 267 }, + { p268: 268 }, + { p269: 269 }, + { p270: 270 }, + { p271: 271 }, + { p272: 272 }, + { p273: 273 }, + { p274: 274 }, + { p275: 275 }, + { p276: 276 }, + { p277: 277 }, + { p278: 278 }, + { p279: 279 }, + { p280: 280 }, + { p281: 281 }, + { p282: 282 }, + { p283: 283 }, + { p284: 284 }, + { p285: 285 }, + { p286: 286 }, + { p287: 287 }, + { p288: 288 }, + { p289: 289 }, + { p290: 290 }, + { p291: 291 }, + { p292: 292 }, + { p293: 293 }, + { p294: 294 }, + { p295: 295 }, + { p296: 296 }, + { p297: 297 }, + { p298: 298 }, + { p299: 299 }, + { p300: 300 }, + { p301: 301 }, + { p302: 302 }, + { p303: 303 }, + { p304: 304 }, + { p305: 305 }, + { p306: 306 }, + { p307: 307 }, + { p308: 308 }, + { p309: 309 }, + { p310: 310 }, + { p311: 311 }, + { p312: 312 }, + { p313: 313 }, + { p314: 314 }, + { p315: 315 }, + { p316: 316 }, + { p317: 317 }, + { p318: 318 }, + { p319: 319 }, + { p320: 320 }, + { p321: 321 }, + { p322: 322 }, + { p323: 323 }, + { p324: 324 }, + { p325: 325 }, + { p326: 326 }, + { p327: 327 }, + { p328: 328 }, + { p329: 329 }, + { p330: 330 }, + { p331: 331 }, + { p332: 332 }, + { p333: 333 }, + { p334: 334 }, + { p335: 335 }, + { p336: 336 }, + { p337: 337 }, + { p338: 338 }, + { p339: 339 }, + { p340: 340 }, + { p341: 341 }, + { p342: 342 }, + { p343: 343 }, + { p344: 344 }, + { p345: 345 }, + { p346: 346 }, + { p347: 347 }, + { p348: 348 }, + { p349: 349 }, + { p350: 350 }, + { p351: 351 }, + { p352: 352 }, + { p353: 353 }, + { p354: 354 }, + { p355: 355 }, + { p356: 356 }, + { p357: 357 }, + { p358: 358 }, + { p359: 359 }, + { p360: 360 }, + { p361: 361 }, + { p362: 362 }, + { p363: 363 }, + { p364: 364 }, + { p365: 365 }, + { p366: 366 }, + { p367: 367 }, + { p368: 368 }, + { p369: 369 }, + { p370: 370 }, + { p371: 371 }, + { p372: 372 }, + { p373: 373 }, + { p374: 374 }, + { p375: 375 }, + { p376: 376 }, + { p377: 377 }, + { p378: 378 }, + { p379: 379 }, + { p380: 380 }, + { p381: 381 }, + { p382: 382 }, + { p383: 383 }, + { p384: 384 }, + { p385: 385 }, + { p386: 386 }, + { p387: 387 }, + { p388: 388 }, + { p389: 389 }, + { p390: 390 }, + { p391: 391 }, + { p392: 392 }, + { p393: 393 }, + { p394: 394 }, + { p395: 395 }, + { p396: 396 }, + { p397: 397 }, + { p398: 398 }, + { p399: 399 }, + { p400: 400 }, + { p401: 401 }, + { p402: 402 }, + { p403: 403 }, + { p404: 404 }, + { p405: 405 }, + { p406: 406 }, + { p407: 407 }, + { p408: 408 }, + { p409: 409 }, + { p410: 410 }, + { p411: 411 }, + { p412: 412 }, + { p413: 413 }, + { p414: 414 }, + { p415: 415 }, + { p416: 416 }, + { p417: 417 }, + { p418: 418 }, + { p419: 419 }, + { p420: 420 }, + { p421: 421 }, + { p422: 422 }, + { p423: 423 }, + { p424: 424 }, + { p425: 425 }, + { p426: 426 }, + { p427: 427 }, + { p428: 428 }, + { p429: 429 }, + { p430: 430 }, + { p431: 431 }, + { p432: 432 }, + { p433: 433 }, + { p434: 434 }, + { p435: 435 }, + { p436: 436 }, + { p437: 437 }, + { p438: 438 }, + { p439: 439 }, + { p440: 440 }, + { p441: 441 }, + { p442: 442 }, + { p443: 443 }, + { p444: 444 }, + { p445: 445 }, + { p446: 446 }, + { p447: 447 }, + { p448: 448 }, + { p449: 449 }, + { p450: 450 }, + { p451: 451 }, + { p452: 452 }, + { p453: 453 }, + { p454: 454 }, + { p455: 455 }, + { p456: 456 }, + { p457: 457 }, + { p458: 458 }, + { p459: 459 }, + { p460: 460 }, + { p461: 461 }, + { p462: 462 }, + { p463: 463 }, + { p464: 464 }, + { p465: 465 }, + { p466: 466 }, + { p467: 467 }, + { p468: 468 }, + { p469: 469 }, + { p470: 470 }, + { p471: 471 }, + { p472: 472 }, + { p473: 473 }, + { p474: 474 }, + { p475: 475 }, + { p476: 476 }, + { p477: 477 }, + { p478: 478 }, + { p479: 479 }, + { p480: 480 }, + { p481: 481 }, + { p482: 482 }, + { p483: 483 }, + { p484: 484 }, + { p485: 485 }, + { p486: 486 }, + { p487: 487 }, + { p488: 488 }, + { p489: 489 }, + { p490: 490 }, + { p491: 491 }, + { p492: 492 }, + { p493: 493 }, + { p494: 494 }, + { p495: 495 }, + { p496: 496 }, + { p497: 497 }, + { p498: 498 }, + { p499: 499 }, + { p500: 500 }, + { p501: 501 }, + { p502: 502 }, + { p503: 503 }, + { p504: 504 }, + { p505: 505 }, + { p506: 506 }, + { p507: 507 }, + { p508: 508 }, + { p509: 509 }, + { p510: 510 }, + { p511: 511 }, + { p512: 512 }, + { p513: 513 }, + { p514: 514 }, + { p515: 515 }, + { p516: 516 }, + { p517: 517 }, + { p518: 518 }, + { p519: 519 }, + { p520: 520 }, + { p521: 521 }, + { p522: 522 }, + { p523: 523 }, + { p524: 524 }, + { p525: 525 }, + { p526: 526 }, + { p527: 527 }, + { p528: 528 }, + { p529: 529 }, + { p530: 530 }, + { p531: 531 }, + { p532: 532 }, + { p533: 533 }, + { p534: 534 }, + { p535: 535 }, + { p536: 536 }, + { p537: 537 }, + { p538: 538 }, + { p539: 539 }, + { p540: 540 }, + { p541: 541 }, + { p542: 542 }, + { p543: 543 }, + { p544: 544 }, + { p545: 545 }, + { p546: 546 }, + { p547: 547 }, + { p548: 548 }, + { p549: 549 }, + { p550: 550 }, + { p551: 551 }, + { p552: 552 }, + { p553: 553 }, + { p554: 554 }, + { p555: 555 }, + { p556: 556 }, + { p557: 557 }, + { p558: 558 }, + { p559: 559 }, + { p560: 560 }, + { p561: 561 }, + { p562: 562 }, + { p563: 563 }, + { p564: 564 }, + { p565: 565 }, + { p566: 566 }, + { p567: 567 }, + { p568: 568 }, + { p569: 569 }, + { p570: 570 }, + { p571: 571 }, + { p572: 572 }, + { p573: 573 }, + { p574: 574 }, + { p575: 575 }, + { p576: 576 }, + { p577: 577 }, + { p578: 578 }, + { p579: 579 }, + { p580: 580 }, + { p581: 581 }, + { p582: 582 }, + { p583: 583 }, + { p584: 584 }, + { p585: 585 }, + { p586: 586 }, + { p587: 587 }, + { p588: 588 }, + { p589: 589 }, + { p590: 590 }, + { p591: 591 }, + { p592: 592 }, + { p593: 593 }, + { p594: 594 }, + { p595: 595 }, + { p596: 596 }, + { p597: 597 }, + { p598: 598 }, + { p599: 599 }, + { p600: 600 }, + { p601: 601 }, + { p602: 602 }, + { p603: 603 }, + { p604: 604 }, + { p605: 605 }, + { p606: 606 }, + { p607: 607 }, + { p608: 608 }, + { p609: 609 }, + { p610: 610 }, + { p611: 611 }, + { p612: 612 }, + { p613: 613 }, + { p614: 614 }, + { p615: 615 }, + { p616: 616 }, + { p617: 617 }, + { p618: 618 }, + { p619: 619 }, + { p620: 620 }, + { p621: 621 }, + { p622: 622 }, + { p623: 623 }, + { p624: 624 }, + { p625: 625 }, + { p626: 626 }, + { p627: 627 }, + { p628: 628 }, + { p629: 629 }, + { p630: 630 }, + { p631: 631 }, + { p632: 632 }, + { p633: 633 }, + { p634: 634 }, + { p635: 635 }, + { p636: 636 }, + { p637: 637 }, + { p638: 638 }, + { p639: 639 }, + { p640: 640 }, + { p641: 641 }, + { p642: 642 }, + { p643: 643 }, + { p644: 644 }, + { p645: 645 }, + { p646: 646 }, + { p647: 647 }, + { p648: 648 }, + { p649: 649 }, + { p650: 650 }, + { p651: 651 }, + { p652: 652 }, + { p653: 653 }, + { p654: 654 }, + { p655: 655 }, + { p656: 656 }, + { p657: 657 }, + { p658: 658 }, + { p659: 659 }, + { p660: 660 }, + { p661: 661 }, + { p662: 662 }, + { p663: 663 }, + { p664: 664 }, + { p665: 665 }, + { p666: 666 }, + { p667: 667 }, + { p668: 668 }, + { p669: 669 }, + { p670: 670 }, + { p671: 671 }, + { p672: 672 }, + { p673: 673 }, + { p674: 674 }, + { p675: 675 }, + { p676: 676 }, + { p677: 677 }, + { p678: 678 }, + { p679: 679 }, + { p680: 680 }, + { p681: 681 }, + { p682: 682 }, + { p683: 683 }, + { p684: 684 }, + { p685: 685 }, + { p686: 686 }, + { p687: 687 }, + { p688: 688 }, + { p689: 689 }, + { p690: 690 }, + { p691: 691 }, + { p692: 692 }, + { p693: 693 }, + { p694: 694 }, + { p695: 695 }, + { p696: 696 }, + { p697: 697 }, + { p698: 698 }, + { p699: 699 }, + { p700: 700 }, + { p701: 701 }, + { p702: 702 }, + { p703: 703 }, + { p704: 704 }, + { p705: 705 }, + { p706: 706 }, + { p707: 707 }, + { p708: 708 }, + { p709: 709 }, + { p710: 710 }, + { p711: 711 }, + { p712: 712 }, + { p713: 713 }, + { p714: 714 }, + { p715: 715 }, + { p716: 716 }, + { p717: 717 }, + { p718: 718 }, + { p719: 719 }, + { p720: 720 }, + { p721: 721 }, + { p722: 722 }, + { p723: 723 }, + { p724: 724 }, + { p725: 725 }, + { p726: 726 }, + { p727: 727 }, + { p728: 728 }, + { p729: 729 }, + { p730: 730 }, + { p731: 731 }, + { p732: 732 }, + { p733: 733 }, + { p734: 734 }, + { p735: 735 }, + { p736: 736 }, + { p737: 737 }, + { p738: 738 }, + { p739: 739 }, + { p740: 740 }, + { p741: 741 }, + { p742: 742 }, + { p743: 743 }, + { p744: 744 }, + { p745: 745 }, + { p746: 746 }, + { p747: 747 }, + { p748: 748 }, + { p749: 749 }, + { p750: 750 }, + { p751: 751 }, + { p752: 752 }, + { p753: 753 }, + { p754: 754 }, + { p755: 755 }, + { p756: 756 }, + { p757: 757 }, + { p758: 758 }, + { p759: 759 }, + { p760: 760 }, + { p761: 761 }, + { p762: 762 }, + { p763: 763 }, + { p764: 764 }, + { p765: 765 }, + { p766: 766 }, + { p767: 767 }, + { p768: 768 }, + { p769: 769 }, + { p770: 770 }, + { p771: 771 }, + { p772: 772 }, + { p773: 773 }, + { p774: 774 }, + { p775: 775 }, + { p776: 776 }, + { p777: 777 }, + { p778: 778 }, + { p779: 779 }, + { p780: 780 }, + { p781: 781 }, + { p782: 782 }, + { p783: 783 }, + { p784: 784 }, + { p785: 785 }, + { p786: 786 }, + { p787: 787 }, + { p788: 788 }, + { p789: 789 }, + { p790: 790 }, + { p791: 791 }, + { p792: 792 }, + { p793: 793 }, + { p794: 794 }, + { p795: 795 }, + { p796: 796 }, + { p797: 797 }, + { p798: 798 }, + { p799: 799 }, + { p800: 800 }, + { p801: 801 }, + { p802: 802 }, + { p803: 803 }, + { p804: 804 }, + { p805: 805 }, + { p806: 806 }, + { p807: 807 }, + { p808: 808 }, + { p809: 809 }, + { p810: 810 }, + { p811: 811 }, + { p812: 812 }, + { p813: 813 }, + { p814: 814 }, + { p815: 815 }, + { p816: 816 }, + { p817: 817 }, + { p818: 818 }, + { p819: 819 }, + { p820: 820 }, + { p821: 821 }, + { p822: 822 }, + { p823: 823 }, + { p824: 824 }, + { p825: 825 }, + { p826: 826 }, + { p827: 827 }, + { p828: 828 }, + { p829: 829 }, + { p830: 830 }, + { p831: 831 }, + { p832: 832 }, + { p833: 833 }, + { p834: 834 }, + { p835: 835 }, + { p836: 836 }, + { p837: 837 }, + { p838: 838 }, + { p839: 839 }, + { p840: 840 }, + { p841: 841 }, + { p842: 842 }, + { p843: 843 }, + { p844: 844 }, + { p845: 845 }, + { p846: 846 }, + { p847: 847 }, + { p848: 848 }, + { p849: 849 }, + { p850: 850 }, + { p851: 851 }, + { p852: 852 }, + { p853: 853 }, + { p854: 854 }, + { p855: 855 }, + { p856: 856 }, + { p857: 857 }, + { p858: 858 }, + { p859: 859 }, + { p860: 860 }, + { p861: 861 }, + { p862: 862 }, + { p863: 863 }, + { p864: 864 }, + { p865: 865 }, + { p866: 866 }, + { p867: 867 }, + { p868: 868 }, + { p869: 869 }, + { p870: 870 }, + { p871: 871 }, + { p872: 872 }, + { p873: 873 }, + { p874: 874 }, + { p875: 875 }, + { p876: 876 }, + { p877: 877 }, + { p878: 878 }, + { p879: 879 }, + { p880: 880 }, + { p881: 881 }, + { p882: 882 }, + { p883: 883 }, + { p884: 884 }, + { p885: 885 }, + { p886: 886 }, + { p887: 887 }, + { p888: 888 }, + { p889: 889 }, + { p890: 890 }, + { p891: 891 }, + { p892: 892 }, + { p893: 893 }, + { p894: 894 }, + { p895: 895 }, + { p896: 896 }, + { p897: 897 }, + { p898: 898 }, + { p899: 899 }, + { p900: 900 }, + { p901: 901 }, + { p902: 902 }, + { p903: 903 }, + { p904: 904 }, + { p905: 905 }, + { p906: 906 }, + { p907: 907 }, + { p908: 908 }, + { p909: 909 }, + { p910: 910 }, + { p911: 911 }, + { p912: 912 }, + { p913: 913 }, + { p914: 914 }, + { p915: 915 }, + { p916: 916 }, + { p917: 917 }, + { p918: 918 }, + { p919: 919 }, + { p920: 920 }, + { p921: 921 }, + { p922: 922 }, + { p923: 923 }, + { p924: 924 }, + { p925: 925 }, + { p926: 926 }, + { p927: 927 }, + { p928: 928 }, + { p929: 929 }, + { p930: 930 }, + { p931: 931 }, + { p932: 932 }, + { p933: 933 }, + { p934: 934 }, + { p935: 935 }, + { p936: 936 }, + { p937: 937 }, + { p938: 938 }, + { p939: 939 }, + { p940: 940 }, + { p941: 941 }, + { p942: 942 }, + { p943: 943 }, + { p944: 944 }, + { p945: 945 }, + { p946: 946 }, + { p947: 947 }, + { p948: 948 }, + { p949: 949 }, + { p950: 950 }, + { p951: 951 }, + { p952: 952 }, + { p953: 953 }, + { p954: 954 }, + { p955: 955 }, + { p956: 956 }, + { p957: 957 }, + { p958: 958 }, + { p959: 959 }, + { p960: 960 }, + { p961: 961 }, + { p962: 962 }, + { p963: 963 }, + { p964: 964 }, + { p965: 965 }, + { p966: 966 }, + { p967: 967 }, + { p968: 968 }, + { p969: 969 }, + { p970: 970 }, + { p971: 971 }, + { p972: 972 }, + { p973: 973 }, + { p974: 974 }, + { p975: 975 }, + { p976: 976 }, + { p977: 977 }, + { p978: 978 }, + { p979: 979 }, + { p980: 980 }, + { p981: 981 }, + { p982: 982 }, + { p983: 983 }, + { p984: 984 }, + { p985: 985 }, + { p986: 986 }, + { p987: 987 }, + { p988: 988 }, + { p989: 989 }, + { p990: 990 }, + { p991: 991 }, + { p992: 992 }, + { p993: 993 }, + { p994: 994 }, + { p995: 995 }, + { p996: 996 }, + { p997: 997 }, + { p998: 998 }, + { p999: 999 }, + { p1000: 1000 }, + { p1001: 1001 }, + { p1002: 1002 }, + { p1003: 1003 }, + { p1004: 1004 }, + { p1005: 1005 }, + { p1006: 1006 }, + { p1007: 1007 }, + { p1008: 1008 }, + { p1009: 1009 }, + { p1010: 1010 }, + { p1011: 1011 }, + { p1012: 1012 }, + { p1013: 1013 }, + { p1014: 1014 }, + { p1015: 1015 }, + { p1016: 1016 }, + { p1017: 1017 }, + { p1018: 1018 }, + { p1019: 1019 }, + { p1020: 1020 }, + { p1021: 1021 }, + { p1022: 1022 }, + { p1023: 1023 }, + { p1024: 1024 }, + { p1025: 1025 }, + { p1026: 1026 }, + { p1027: 1027 }, + { p1028: 1028 }, + { p1029: 1029 }, + { p1030: 1030 }, + { p1031: 1031 }, + { p1032: 1032 }, + { p1033: 1033 }, + { p1034: 1034 }, + { p1035: 1035 }, + { p1036: 1036 }, + { p1037: 1037 }, + { p1038: 1038 }, + { p1039: 1039 }, + { p1040: 1040 }, + { p1041: 1041 }, + { p1042: 1042 }, + { p1043: 1043 }, + { p1044: 1044 }, + { p1045: 1045 }, + { p1046: 1046 }, + { p1047: 1047 }, + { p1048: 1048 }, + { p1049: 1049 }, + { p1050: 1050 }, + { p1051: 1051 }, + { p1052: 1052 }, + { p1053: 1053 }, + { p1054: 1054 }, + { p1055: 1055 }, + { p1056: 1056 }, + { p1057: 1057 }, + { p1058: 1058 }, + { p1059: 1059 }, + { p1060: 1060 }, + { p1061: 1061 }, + { p1062: 1062 }, + { p1063: 1063 }, + { p1064: 1064 }, + { p1065: 1065 }, + { p1066: 1066 }, + { p1067: 1067 }, + { p1068: 1068 }, + { p1069: 1069 }, + { p1070: 1070 }, + { p1071: 1071 }, + { p1072: 1072 }, + { p1073: 1073 }, + { p1074: 1074 }, + { p1075: 1075 }, + { p1076: 1076 }, + { p1077: 1077 }, + { p1078: 1078 }, + { p1079: 1079 }, + { p1080: 1080 }, + { p1081: 1081 }, + { p1082: 1082 }, + { p1083: 1083 }, + { p1084: 1084 }, + { p1085: 1085 }, + { p1086: 1086 }, + { p1087: 1087 }, + { p1088: 1088 }, + { p1089: 1089 }, + { p1090: 1090 }, + { p1091: 1091 }, + { p1092: 1092 }, + { p1093: 1093 }, + { p1094: 1094 }, + { p1095: 1095 }, + { p1096: 1096 }, + { p1097: 1097 }, + { p1098: 1098 }, + { p1099: 1099 }, +]; diff --git a/test-files/test_gap_recur_class_id_unique.ts b/test-files/test_gap_recur_class_id_unique.ts new file mode 100644 index 0000000000..fbba73d049 --- /dev/null +++ b/test-files/test_gap_recur_class_id_unique.ts @@ -0,0 +1,18 @@ +// recur2: generic class specializations must not reuse an object-literal +// class ID from another module. That collision made the shape claim that +// Recursor instances inherit Object.prototype and dropped recur on clones. +import { literals } from "./_helpers/recur_class_id_literals.ts"; +class Recursor { + value: T; + constructor(value: T) { this.value = value; } + recur(n: number): number { return Number(this.value) + n; } +} +class Other { recur(n: number): number { return 100 + n; } } +const original = new Recursor(5); +const clone = Object.create(Object.getPrototypeOf(original), Object.getOwnPropertyDescriptors(original)); +console.log(literals.length); +console.log(Object.getPrototypeOf(original) === Recursor.prototype); +console.log(Object.getPrototypeOf(original) === Object.prototype); +function invoke(value: any): number { return value.recur(7); } +console.log(invoke(new Other())); +console.log(invoke(clone));