Skip to content

Commit

Permalink
Report closest ancestor in overrides, not farthest, matching document…
Browse files Browse the repository at this point in the history
…ation. (#187)
  • Loading branch information
RomainMuller authored Aug 17, 2018
1 parent ecbe6ed commit 62a2e9f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
10 changes: 5 additions & 5 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -1569,7 +1569,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -1662,7 +1662,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -2745,7 +2745,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -2838,5 +2838,5 @@
}
},
"version": "0.6.4",
"fingerprint": "w6KwhZtZH4/dMIvQlPb9nAIbic1GnqUVTSxVuf7TKbU="
"fingerprint": "J/33pyDX7y9AI1Vizdu+HEO/87ED05WoSxg41CSYHtw="
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -1569,7 +1569,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -1662,7 +1662,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -2745,7 +2745,7 @@
},
"name": "toString",
"overrides": {
"fqn": "@scope/jsii-calc-lib.Value"
"fqn": "@scope/jsii-calc-lib.Operation"
},
"returns": {
"primitive": "string"
Expand Down Expand Up @@ -2838,5 +2838,5 @@
}
},
"version": "0.6.4",
"fingerprint": "w6KwhZtZH4/dMIvQlPb9nAIbic1GnqUVTSxVuf7TKbU="
"fingerprint": "J/33pyDX7y9AI1Vizdu+HEO/87ED05WoSxg41CSYHtw="
}
28 changes: 7 additions & 21 deletions packages/jsii-runtime/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions packages/jsii/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,10 @@ function validateOverriddenSignatures(mod: spec.Assembly, externalTypes: Map<str
throw new Error(`${where}: parameter ${i + 1} type changed from ${orig} (in ${ancestorFqn}) to ${cur}`);
}
}
if (currentFqn !== ancestorFqn) { currentMethod.overrides = { fqn: ancestorFqn }; }
// Register the closest ancestor that is being overridden
if (!currentMethod.overrides && currentFqn !== ancestorFqn) {
currentMethod.overrides = { fqn: ancestorFqn };
}
}

function validateProperty(currentProperty: spec.Property, ancestorProperty: spec.Property) {
Expand All @@ -1368,7 +1371,10 @@ function validateOverriddenSignatures(mod: spec.Assembly, externalTypes: Map<str

throw new Error(`${currentFqn}.${currentProperty.name}: type changed from ${orig} (in ${ancestorFqn}) to ${cur}`);
}
if (currentFqn !== ancestorFqn) { currentProperty.overrides = { fqn: ancestorFqn }; }
// Register the closest ancestor that is being overridden
if (!currentProperty.overrides && currentFqn !== ancestorFqn) {
currentProperty.overrides = { fqn: ancestorFqn };
}
}
}

Expand Down

0 comments on commit 62a2e9f

Please sign in to comment.