-
Notifications
You must be signed in to change notification settings - Fork 451
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
Change return type of raise to Nothing #2839
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ class EffectSpec : | |
val promise = CompletableDeferred<Int>() | ||
effect { | ||
try { | ||
raise<Int>(s().suspend()) | ||
raise(s().suspend()) | ||
} finally { | ||
require(promise.complete(i())) | ||
} | ||
|
@@ -132,7 +132,7 @@ class EffectSpec : | |
"short-circuit" { | ||
checkAll(Arb.string().suspend()) { msg -> | ||
effect { | ||
raise<Int>(msg()) | ||
raise(msg()) | ||
}.runCont() shouldBe msg() | ||
} | ||
} | ||
|
@@ -299,31 +299,34 @@ class EffectSpec : | |
} | ||
} | ||
|
||
@Suppress("UNREACHABLE_CODE") | ||
"catch - error path and recover" { | ||
checkAll(Arb.int().suspend(), Arb.string().suspend()) { int, fallback -> | ||
effect<Int, String> { | ||
raise<String>(int()) | ||
raise(int()) | ||
fail("It should never reach this point") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line now warns about unreachable code. Same in the other similar tests. Is this line still useful, or should it be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that test is still useful. It verifies that passed So, I think we should suppress this warning if possible. (Not sure what |
||
}.recover<Int, Nothing, String> { fallback() } | ||
.runCont() shouldBe fallback() | ||
} | ||
} | ||
|
||
@Suppress("UNREACHABLE_CODE") | ||
"catch - error path and re-raise" { | ||
checkAll(Arb.int().suspend(), Arb.string().suspend()) { int, fallback -> | ||
effect<Int, Unit> { | ||
raise<String>(int()) | ||
raise(int()) | ||
fail("It should never reach this point") | ||
}.recover { raise(fallback()) } | ||
.runCont() shouldBe fallback() | ||
} | ||
} | ||
|
||
@Suppress("UNREACHABLE_CODE") | ||
"catch - error path and throw" { | ||
checkAll(Arb.int().suspend(), Arb.string().suspend()) { int, msg -> | ||
shouldThrow<RuntimeException> { | ||
effect<Int, String> { | ||
raise<String>(int()) | ||
raise(int()) | ||
fail("It should never reach this point") | ||
}.recover<Int, Nothing, String> { throw RuntimeException(msg()) } | ||
.runCont() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explicit lambda signature is needed here because otherwise the type of
b
is unconstrained and the+
operator function can't be resolved.