Skip to content

Commit 8d11900

Browse files
rix0rrrRomainMuller
authored andcommitted
fix(jsii-diff): catch exception if type disappeared from other assembly (#504)
Make jsii-diff not crash in the following case: - Assembly A depends on Assembly B, and they both update simultaneously. - Assembly A' uses a return type T' freshly introduced in Assembly B'. When doing the supertype check, the compatibility check of A -> A', the lookup of T' inside B would lead to an exception, which would crash the tool.
1 parent d1d0633 commit 8d11900

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

packages/jsii-diff/lib/type-analysis.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ export function isSuperType(a: reflect.TypeReference, b: reflect.TypeReference,
6464
// and the NEW type system.
6565
// We could do more complex analysis on typing of methods, but it doesn't seem
6666
// worth it.
67-
const A = a.type!; // Note: lookup in old type system!
68-
const B = b.type!;
69-
if (A.isInterfaceType() && A.isDataType() && B.isInterfaceType() && B.datatype) {
70-
return isStructuralSuperType(A, B, updatedSystem);
67+
try {
68+
const A = a.type!; // Note: lookup in old type system!
69+
const B = b.type!;
70+
if (A.isInterfaceType() && A.isDataType() && B.isInterfaceType() && B.datatype) {
71+
return isStructuralSuperType(A, B, updatedSystem);
72+
}
73+
} catch (e) {
74+
// We might get an exception if the type is supposed to come from a different
75+
// assembly and the lookup fails.
76+
return { success: false, reasons: [e.message] };
7177
}
7278

7379
// All seems good

0 commit comments

Comments
 (0)