Skip to content

Commit

Permalink
fix TypeAssigner: don't fail completely if type is not augmentable
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Oct 6, 2023
1 parent 08b6ee4 commit cd42555
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public Type evaluate(
if (value instanceof Immediate) {
if (value instanceof Local) {
return typing.getType((Local) value);
// if value instanceof Constant
} else {
} else if (value instanceof Constant) {
if (value.getClass() == IntConstant.class) {
int val = ((IntConstant) value).getValue();
if (val >= 0 && val < 2) {
Expand Down Expand Up @@ -123,9 +122,7 @@ public Type evaluate(
} else if (value.getClass() == MethodType.class) {
return methodTypeClassType;
} else {
// return null;
throw new RuntimeException(
"can't evaluatable constant in AugEvalFunction '" + value + "'.");
throw new IllegalStateException("can't evaluate this type of Constant '" + value + "'.");
}
}
} else if (value instanceof Expr) {
Expand Down Expand Up @@ -203,12 +200,6 @@ public Type evaluate(
type = getLeastCommonExceptionType(type, exceptionType);
}
}

if (type == null) {
return null;
// throw new RuntimeException("can't evaluatable reference in AugEvalFunction '" + value +
// "'.");
}
return type;
} else if (value instanceof JArrayRef) {
Type type = typing.getType(((JArrayRef) value).getBase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void visit(@Nonnull Value value, @Nonnull Type stdType, @Nonnull Stmt stm
BytecodeHierarchy hierarchy = getHierarchy();
Typing typing = getTyping();
Type evaType = evalFunction.evaluate(typing, value, stmt, graph);
if (evaType.equals(stdType)) {
if (evaType == null || evaType.equals(stdType)) {
return;
}
if (!hierarchy.isAncestor(stdType, evaType)) {
Expand Down
Loading

0 comments on commit cd42555

Please sign in to comment.