Skip to content

Commit

Permalink
Add check against downgrading proeprties to readonly (#201)
Browse files Browse the repository at this point in the history
Fixes #199
  • Loading branch information
RomainMuller authored Aug 26, 2018
1 parent f25c8c4 commit f60b0ac
Show file tree
Hide file tree
Showing 3 changed files with 645 additions and 195 deletions.
5 changes: 5 additions & 0 deletions packages/jsii/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,11 @@ function validateOverriddenSignatures(mod: spec.Assembly, externalTypes: Map<str

throw new Error(`${currentFqn}.${currentProperty.name}: type changed from ${orig} (in ${ancestorFqn}) to ${cur}`);
}
if (!!currentProperty.immutable !== !!ancestorProperty.immutable) {
const orig = ancestorProperty.immutable ? 'readonly' : 'read-write';
const cur = currentProperty.immutable ? 'readonly' : 'read-write';
throw new Error(`${currentFqn}.${currentProperty.name}: immutability changed from ${orig} (in ${ancestorFqn}) to ${cur}`);
}
// Register the closest ancestor that is being overridden
if (!currentProperty.overrides && currentFqn !== ancestorFqn) {
currentProperty.overrides = { fqn: ancestorFqn };
Expand Down
Loading

0 comments on commit f60b0ac

Please sign in to comment.