Skip to content

Commit

Permalink
Simplify casts with instanceof pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed Jul 10, 2023
1 parent c22852e commit 18aaca2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions enigma/src/main/java/cuchaz/enigma/source/jadx/JadxSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,13 @@ private List<VarNode> getMethodArgs(MethodNode mth, ICodeInfo codeInfo) {
return Boolean.TRUE;
}

if (ann instanceof NodeDeclareRef) {
ICodeNodeRef declRef = ((NodeDeclareRef) ann).getNode();

if (declRef instanceof VarNode) {
VarNode varNode = (VarNode) declRef;

if (!varNode.getMth().equals(mth)) {
// Stop if we've gone too far and have entered a different method
return Boolean.TRUE;
}

args.add(varNode);
if (ann instanceof NodeDeclareRef ref && ref.getNode() instanceof VarNode varNode) {
if (!varNode.getMth().equals(mth)) {
// Stop if we've gone too far and have entered a different method
return Boolean.TRUE;
}

args.add(varNode);
}

return null;
Expand Down

0 comments on commit 18aaca2

Please sign in to comment.