-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always split switch expressions (#1537)
Always split switch expressions. I figured that since other comma-delimited expression forms don't split if they don't have to, switch expressions should be the same. But I went and checked on a huge corpus and every single place where a switch expression wasn't split was clearly much worse than splitting it would be. Fix #1529.
- Loading branch information
1 parent
02d5bc2
commit 5749a94
Showing
5 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
>>> (indent 4) | ||
return switch (that) { Family() => that, $FamilyOverride() => that.from }; | ||
<<< | ||
return switch (that) { | ||
Family() => that, | ||
$FamilyOverride() => that.from, | ||
}; | ||
>>> (indent 6) | ||
x = switch (event) { | ||
ProviderDisposeEvent() => switch (event | ||
.debugOrigin) { ProviderDisposeEvent e => [e.refenaId], _ => null }, | ||
}; | ||
<<< | ||
x = switch (event) { | ||
ProviderDisposeEvent() => switch (event.debugOrigin) { | ||
ProviderDisposeEvent e => [e.refenaId], | ||
_ => null, | ||
}, | ||
}; | ||
>>> (indent 6) | ||
x = switch (event) { | ||
RebuildEvent() => switch (event | ||
.debugOrigin) { BaseReduxAction a => a.refenaId, _ => null }, | ||
ActionDispatchedEvent() => switch (event | ||
.debugOriginRef) { BaseReduxAction a => a.refenaId, _ => null }, | ||
MessageEvent() => switch (event | ||
.origin) { BaseReduxAction a => a.refenaId, _ => null }, | ||
}; | ||
<<< | ||
x = switch (event) { | ||
RebuildEvent() => switch (event.debugOrigin) { | ||
BaseReduxAction a => a.refenaId, | ||
_ => null, | ||
}, | ||
ActionDispatchedEvent() => switch (event.debugOriginRef) { | ||
BaseReduxAction a => a.refenaId, | ||
_ => null, | ||
}, | ||
MessageEvent() => switch (event.origin) { | ||
BaseReduxAction a => a.refenaId, | ||
_ => null, | ||
}, | ||
}; | ||
>>> (indent 2) | ||
T? valueOrNull() => switch (this) { Data(:var value) => value, _ => null }; | ||
<<< | ||
T? valueOrNull() => switch (this) { | ||
Data(:var value) => value, | ||
_ => null, | ||
}; | ||
>>> (indent 2) | ||
String transcription(Locale intl) => switch (intl | ||
.languageCode) { 'zh' => zhCN(this), 'be' => be(this), _ => basic(this) }; | ||
<<< | ||
String transcription(Locale intl) => switch (intl.languageCode) { | ||
'zh' => zhCN(this), | ||
'be' => be(this), | ||
_ => basic(this), | ||
}; | ||
>>> (indent 4) | ||
return switch (x) { <= 1 => x, >= 3 => x - 4, _ => 2 - x }; | ||
<<< | ||
return switch (x) { | ||
<= 1 => x, | ||
>= 3 => x - 4, | ||
_ => 2 - x, | ||
}; |