Skip to content

Commit

Permalink
Preserve tabular arguments for mixed sign numeric lists.
Browse files Browse the repository at this point in the history
Treats unary minus literals (eg -4.0) as their underlying type when checking if all elements in a tabular list are of the same Tree.Kind.

Fixes #400, #406

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=303137504
  • Loading branch information
andrewkreid authored and nick-someone committed Mar 26, 2020
1 parent d6d0b4d commit b810032
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3192,7 +3192,13 @@ private static boolean expressionsAreParallel(
if (column >= row.size()) {
continue;
}
nodeTypes.add(row.get(column).getKind());
// Treat UnaryTree expressions as their underlying type for the comparison (so, for example
// -ve and +ve numeric literals are considered the same).
if (row.get(column) instanceof UnaryTree) {
nodeTypes.add(((UnaryTree) row.get(column)).getExpression().getKind());
} else {
nodeTypes.add(row.get(column).getKind());
}
}
for (Multiset.Entry<Tree.Kind> nodeType : nodeTypes.entrySet()) {
if (nodeType.getCount() >= atLeastM) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class T {
private static final double[] f = {
95.0, 75.0, -95.0, 75.0,
-95.0, 75.0, +95.0, 75.0
};

private static final int[] g = {
x++, y, ++z,
x, y, ~z,
--x, ++y, z--
};

private static final bool[] h = {
a, b, c, d,
!e, a, b, c
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class T {
private static final double[] f = {
95.0, 75.0, -95.0, 75.0,
-95.0, 75.0, +95.0, 75.0
};

private static final int[] g = {
x++, y, ++z,
x, y, ~z,
--x, ++y, z--
};

private static final bool[] h = {
a, b, c, d,
!e, a, b, c
};
}

0 comments on commit b810032

Please sign in to comment.