-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatter fails when complex case
is part of switch expression
#922
Comments
I'm using https://github.com/spotify/fmt-maven-plugin which imports The error:
The code: KiwiNode readTail(boolean dotOK) throws IOException {
var token = nextToken();
return switch (token) {
case String s when s.equals(EOF) -> throw new RuntimeException("EOF during read");
case String s when s.equals(")") -> ListNode.of();
case String s when s.equals(".") -> {
var result = read();
token = nextToken();
if (token != ")") warn("Where's the ')'? Got " + token + " after .");
yield result;
}
default -> {
isPushedToken = true;
pushedToken = token;
yield ListNode.cons(read(), readTail(true));
}
};
} |
I'm using 1.18.1 via prettier, this issue is still not resolved. |
I've seen afterward, but I have no competence for judging it. I've noticed that your PR was not processed forward because of the CLA agreement that you didn't signed. Have you signed it since ? |
@benzen yeah I did. The check is green now. I think it needs some manual intervention though. |
After the changes in 430ba3b and b86c508, the formatter handles examples like #922 (comment): class T {
KiwiNode readTail(boolean dotOK) throws IOException {
var token = nextToken();
return switch (token) {
case String s when s.equals(EOF) -> throw new RuntimeException("EOF during read");
case String s when s.equals(")") -> ListNode.of();
case String s when s.equals(".") -> {
var result = read();
token = nextToken();
if (token != ")") warn("Where's the ')'? Got " + token + " after .");
yield result;
}
default -> {
isPushedToken = true;
pushedToken = token;
yield ListNode.cons(read(), readTail(true));
}
};
}
} |
Environment :
id("com.diffplug.spotless") version "6.15.0"
SpotLess configuration :
Issue with complex case :
case ReachableByEmail c && (c instanceof ReachableByPhone)
Thrown errors
Caused by: com.google.googlejavaformat.java.FormatterException: 8:13: error: expected token: '&'; generated ( instead
andjava.lang.reflect.InvocationTargetException
The text was updated successfully, but these errors were encountered: