Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(WIP) fix
  • Loading branch information
Godin committed Apr 16, 2025
commit c7826a08105c58a064422295793703d83683b14a
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,26 @@ final class KotlinSafeCallOperatorFilter implements IFilter {
public void filter(final MethodNode methodNode,
final IFilterContext context, final IFilterOutput output) {
for (final ArrayList<JumpInsnNode> chain : findChains(methodNode)) {
if (chain.size() == 1) {
final AbstractInsnNode ifNonNullInstruction = chain.get(0).label
.getPrevious();
if (chain.size() == 1
&& ifNonNullInstruction.getOpcode() != Opcodes.IFNONNULL) {
continue;
}
final JumpInsnNode lastIfNullInstruction = chain
.get(chain.size() - 1);
final AbstractInsnNode nullTarget = AbstractMatcher
.skipNonOpcodes(lastIfNullInstruction.label);
.skipNonOpcodes(chain.get(0).label);
for (final AbstractInsnNode ifNullInstruction : chain) {
final Replacements replacements = new Replacements();
replacements.add(ifNullInstruction, ifNullInstruction, 0);
replacements.add(nullTarget, nullTarget, 0);
output.replaceBranches(ifNullInstruction, replacements);
}
if (ifNonNullInstruction.getOpcode() == Opcodes.IFNONNULL) {
final Replacements replacements = new Replacements();
replacements.add(nullTarget, nullTarget, 0);
replacements.add(ifNonNullInstruction, ifNonNullInstruction, 1);
output.replaceBranches(ifNonNullInstruction, replacements);
}
}
}

Expand Down