Skip to content

Commit

Permalink
Replace checkState with assert in TypeSignature
Browse files Browse the repository at this point in the history
The assertions are verifying internal invariants of the parser.
  • Loading branch information
electrum committed Jan 5, 2015
1 parent 3563790 commit 7c57167
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public static TypeSignature parseTypeSignature(String signature)
char c = signature.charAt(i);
if (c == '<') {
if (bracketCount == 0) {
checkState(baseName == null, "Expected baseName to be null");
checkState(parameterStart == -1, "Expected parameter start to be -1");
verify(baseName == null, "Expected baseName to be null");
verify(parameterStart == -1, "Expected parameter start to be -1");
baseName = signature.substring(0, i);
parameterStart = i + 1;
}
Expand Down Expand Up @@ -163,8 +163,8 @@ else if (c == '(') {
inLiteralParameters = true;
if (bracketCount == 0) {
if (baseName == null) {
checkState(parameters.isEmpty(), "Expected no parameters");
checkState(parameterStart == -1, "Expected parameter start to be -1");
verify(parameters.isEmpty(), "Expected no parameters");
verify(parameterStart == -1, "Expected parameter start to be -1");
baseName = signature.substring(0, i);
}
parameterStart = i + 1;
Expand Down Expand Up @@ -226,10 +226,10 @@ private static void checkArgument(boolean argument, String format, Object...args
}
}

private static void checkState(boolean argument, String format, Object...args)
private static void verify(boolean argument, String message)
{
if (!argument) {
throw new IllegalStateException(format(format, args));
throw new AssertionError(message);
}
}
}

0 comments on commit 7c57167

Please sign in to comment.