-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...acoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.internal.analysis.filter; | ||
|
||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.Type; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.VarInsnNode; | ||
|
||
public final class KotlinDefaultArgumentsFilter implements IFilter { | ||
|
||
private static final String SUFFIX = "$default"; | ||
|
||
public void filter(final MethodNode methodNode, | ||
final IFilterContext context, final IFilterOutput output) { | ||
if ((methodNode.access & Opcodes.ACC_SYNTHETIC) == 0) { | ||
return; | ||
} | ||
if (!methodNode.name.endsWith(SUFFIX)) { | ||
return; | ||
} | ||
|
||
final int maskVar = Type.getMethodType(methodNode.desc) | ||
.getArgumentTypes().length - 2; | ||
|
||
for (AbstractInsnNode i = methodNode.instructions | ||
.getFirst(); i != null; i = i.getNext()) { | ||
if (AbstractInsnNode.VAR_INSN != i.getType()) { | ||
continue; | ||
} | ||
if (maskVar != ((VarInsnNode) i).var) { | ||
continue; | ||
} | ||
|
||
final AbstractInsnNode jump = i.getNext().getNext().getNext(); | ||
output.ignore(jump, jump); | ||
} | ||
|
||
} | ||
|
||
} |