Skip to content

Commit

Permalink
fix coverity scan issues (#45)
Browse files Browse the repository at this point in the history
* fix coverity scan issues

---------

Signed-off-by: Xu Jun <[email protected]>
  • Loading branch information
xujuntwt95329 authored Oct 30, 2023
1 parent b558f29 commit 23821c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/semantics/expression_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2084,8 +2084,9 @@ function buildNewExpression2(
} else {
const exprObjType = context.module.findValueTypeByType(
expr.exprType,
) as ObjectType;
)! as ObjectType;
if (
exprObjType &&
exprObjType.genericOwner &&
exprObjType.genericType.equals(object_type)
) {
Expand Down
2 changes: 0 additions & 2 deletions src/semantics/statement_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,4 @@ export function buildStatement(
Logger.error(`Source: ${tsNode.getFullText(sourceFile)}`);
throw Error(e);
}

return new EmptyNode();
}
4 changes: 3 additions & 1 deletion src/semantics/type_creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ export function createObjectType(
genericOwner = context.module.findValueTypeByType(
clazz.genericOwner,
) as ObjectType;
inst_type.setGenericOwner(genericOwner.instanceType!);
if (genericOwner) {
inst_type.setGenericOwner(genericOwner.instanceType!);
}
}

if (inst_meta.isObjectInstance) {
Expand Down
6 changes: 3 additions & 3 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ export class TypeResolver {
(type as TSClass).setBelongedScope(this.currentScope!);
}
} else if (ts.isObjectLiteralExpression(node)) {
if (this.currentScope?.parent) {
if (this.currentScope!.parent) {
this.currentScope!.parent!.addType(tsTypeString, type);
}
if (this.currentScope! instanceof ClassScope) {
Expand Down Expand Up @@ -2794,7 +2794,7 @@ export class TypeResolver {

// set the property value of the basic property
if (classType.getBase()) {
const base = classType.getBase();
const base = classType.getBase()!;
const base_typeArguments = base!.typeArguments;

/*
Expand Down Expand Up @@ -2827,7 +2827,7 @@ export class TypeResolver {
const newName =
newType.className +
'_' +
base?.className.split('_').reverse()[0];
base!.className.split('_').reverse()[0];
const newBaseType = TypeResolver.createSpecializedType(
base!,
baseSpecializedArgs,
Expand Down

0 comments on commit 23821c5

Please sign in to comment.