Commit e7ae57e
fix(ruby): const-aware naming and deprecation-based collision resolution
Two real generator gaps surfaced as runtime-broken bindings for the
jsii-calc fixtures `StaticHelloParent`, `Statics`, `UpcasingReflectable`,
`DisappointingCollectionSource`, and `TwoMethodsWithSimilarCapitalization`:
1. `property` + `PROPERTY` (and friends like `foo`/`Foo`/`BAR`/`zooBar`)
both snake_cased to the same Ruby identifier, so the second `def`
silently overwrote the first. Now `const: true` properties take an
UPPER_SNAKE_CASE form (`maybeList` -> `MAYBE_LIST`, `PROPERTY` stays
`PROPERTY`), matching Python's `toPythonPropertyName(name, constant)`.
Ruby parses `Foo.PROPERTY` and `Foo.property` as distinct method
calls, so both coexist without ambiguity.
2. `fooBar`/`fooBAR` and `toIsoString`/`toISOString` still collide after
step 1 because they aren't const. Mirror Python's `prepareMembers`:
drop deprecated members on collision and keep the single
non-deprecated one. Throw if the inputs leave the bug visible
(multiple non-deprecated, or all deprecated).
Side effects:
- Drop `assertNoRubyNameCollisions` / `assertNoEnumConstCollisions`;
their warn-and-last-wins behavior is replaced by the dedup pass
which throws on truly irreconcilable cases.
- Drop the async-static warning. Python documents the same gap
(`PromiseNothing.promise_it` is `#`-commented "TODO: code-gen is
incorrect for static async"), and a real fix requires extending
`BeginRequest` to accept an `fqn` form — a kernel protocol change,
not a Ruby-side fix.
- Update rspec assertions for the four constants that moved from
snake_case to UPPER_SNAKE_CASE.
166 ruby spec tests pass, 32 ruby pacmak snapshots pass, 63
version-utils tests pass, 110 kernel naming tests pass. Zero
generator warnings on the jsii-calc closure.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1e0e4c5 commit e7ae57e
5 files changed
Lines changed: 263 additions & 187 deletions
File tree
- packages
- @jsii/ruby-runtime-test/spec
- jsii-pacmak
- lib/targets
- test/generated-code/__snapshots__
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
0 commit comments