Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3621,15 +3621,10 @@ int declareOne(
initializer.get().accept(this, null);
builder.close();
} else {
if (builder.peekToken().get().equals("switch")) {
// TODO(fawind): Don't break switch expression assignment
builder.open(Indent.If.make(typeBreak, plusFour, ZERO));
} else {
builder.open(
Indent.If.make(typeBreak, plusFour, ZERO),
BreakBehaviours.breakOnlyIfInnerLevelsThenFitOnOneLine(true),
LastLevelBreakability.ABORT);
}
builder.open(
Indent.If.make(typeBreak, plusFour, ZERO),
BreakBehaviours.breakOnlyIfInnerLevelsThenFitOnOneLine(true),
LastLevelBreakability.ABORT);
{
builder.breakToFill(" ");
scan(initializer.get(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ public Void visitCase(CaseTree node, Void unused) {
builder.close();
}
builder.guessToken(";");
builder.forcedBreak(minusTwo);
break;
default:
throw new IllegalArgumentException(node.getCaseKind().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class ExpressionSwitch {
return val;
}

static final int FIELD =
switch (KIND) {
case 0 -> 1;
case 1 -> 2;
default -> throw new IllegalStateException();
};

int wrapping(Wrapping w) {
switch (w) {
case THIS_IS_A_VERY_LONG_ENUM_VALUE_ONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ class ExpressionSwitch {
}

int assignment(int j) {
boolean val =
switch (j) {
case 0 -> true;
case 1 -> false;
default -> false;
};
boolean val = switch (j) {
case 0 -> true;
case 1 -> false;
default -> false;
};
return val;
}

static final int FIELD = switch (KIND) {
case 0 -> 1;
case 1 -> 2;
default -> throw new IllegalStateException();
};

int wrapping(Wrapping w) {
switch (w) {
case THIS_IS_A_VERY_LONG_ENUM_VALUE_ONE,
Expand All @@ -49,12 +54,11 @@ class ExpressionSwitch {
}

public void test1(int y) {
int x =
switch (y) {
case 1 -> 1;
case 2 -> throw new IllegalArgumentException();
default -> throw new IllegalStateException();
};
int x = switch (y) {
case 1 -> 1;
case 2 -> throw new IllegalArgumentException();
default -> throw new IllegalStateException();
};
}

public void test2(int y) {
Expand Down
Loading