fix: hide debug type inference logs

This commit is contained in:
Skylot
2018-12-03 12:36:06 +03:00
parent 95f9ab035d
commit d553157bb3
2 changed files with 6 additions and 8 deletions
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.core.Consts;
import jadx.core.dex.instructions.IndexInsnNode;
import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.instructions.args.LiteralArg;
@@ -67,7 +68,7 @@ public final class TypeInferenceVisitor extends AbstractVisitor {
if (assignArg.isTypeImmutable()) {
ArgType initType = assignArg.getInitType();
TypeUpdateResult result = typeUpdate.apply(ssaVar, initType);
if (result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) {
if (Consts.DEBUG && result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) {
LOG.debug("Initial immutable type set rejected: {} -> {}", ssaVar, initType);
}
} else {
@@ -85,7 +86,7 @@ public final class TypeInferenceVisitor extends AbstractVisitor {
if (bestTypeOpt.isPresent()) {
ArgType candidateType = bestTypeOpt.get();
TypeUpdateResult result = typeUpdate.apply(ssaVar, candidateType);
if (result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) {
if (Consts.DEBUG && result == TypeUpdateResult.REJECT && LOG.isDebugEnabled()) {
if (ssaVar.getTypeInfo().getType().equals(candidateType)) {
LOG.warn("Same type rejected: {} -> {}, bounds: {}", ssaVar, candidateType, bounds);
} else {
@@ -7,10 +7,10 @@ import java.util.Objects;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.core.Consts;
import jadx.core.dex.instructions.InsnType;
import jadx.core.dex.instructions.args.ArgType;
import jadx.core.dex.instructions.args.InsnArg;
@@ -81,7 +81,7 @@ public final class TypeUpdate {
private TypeUpdateResult updateTypeForSsaVar(TypeUpdateInfo updateInfo, SSAVar ssaVar, ArgType candidateType) {
TypeInfo typeInfo = ssaVar.getTypeInfo();
if (!inBounds(typeInfo.getBounds(), candidateType)) {
if (LOG.isDebugEnabled()) {
if (Consts.DEBUG && LOG.isDebugEnabled()) {
LOG.debug("Reject type '{}' for {} by bounds: {}", candidateType, ssaVar, typeInfo.getBounds());
}
return REJECT;
@@ -153,7 +153,6 @@ public final class TypeUpdate {
return true;
}
@Nullable
private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boundType) {
TypeCompareEnum compareResult = comparator.compareTypes(candidateType, boundType);
switch (compareResult) {
@@ -166,9 +165,7 @@ public final class TypeUpdate {
case NARROW:
if (bound.getBound() == BoundEnum.ASSIGN) {
if (boundType.isTypeKnown() || !checkAssignForUnknown(boundType, candidateType)) {
return false;
}
return !boundType.isTypeKnown() && checkAssignForUnknown(boundType, candidateType);
}
return true;