Skip to content

Commit 1fd58db

Browse files
committed
fix(pacmak): crash when generating java code
A missing condition in the code generator could have resulted in attempting to read a property on undefined, resulting in a crash.
1 parent c482bcd commit 1fd58db

File tree

1 file changed

+23
-23
lines changed
  • packages/jsii-pacmak/lib/targets

1 file changed

+23
-23
lines changed

packages/jsii-pacmak/lib/targets/java.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -1603,29 +1603,29 @@ class JavaGenerator extends Generator {
16031603
) {
16041604
if (spec.isUnionTypeReference(type)) {
16051605
validateTypeUnion.call(this, value, descr, type, parameterName);
1606-
} else {
1607-
const collectionType = type as spec.CollectionTypeReference;
1608-
if (collectionType.collection.kind === spec.CollectionKind.Array) {
1609-
validateArray.call(
1610-
this,
1611-
value,
1612-
descr,
1613-
collectionType.collection.elementtype,
1614-
parameterName,
1615-
isRawArray,
1616-
);
1617-
} else if (collectionType.collection.kind === spec.CollectionKind.Map) {
1618-
validateMap.call(
1619-
this,
1620-
value,
1621-
descr,
1622-
collectionType.collection.elementtype,
1623-
parameterName,
1624-
);
1625-
} else {
1626-
throw new Error(
1627-
`Unhandled collection kind: ${spec.describeTypeReference(type)}`,
1628-
);
1606+
} else if (spec.isCollectionTypeReference(type)) {
1607+
switch (type.collection.kind) {
1608+
case spec.CollectionKind.Array:
1609+
return validateArray.call(
1610+
this,
1611+
value,
1612+
descr,
1613+
type.collection.elementtype,
1614+
parameterName,
1615+
isRawArray,
1616+
);
1617+
case spec.CollectionKind.Map:
1618+
return validateMap.call(
1619+
this,
1620+
value,
1621+
descr,
1622+
type.collection.elementtype,
1623+
parameterName,
1624+
);
1625+
default:
1626+
throw new Error(
1627+
`Unhandled collection kind: ${spec.describeTypeReference(type)}`,
1628+
);
16291629
}
16301630
}
16311631
}

0 commit comments

Comments
 (0)