Skip to content
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 when/switch thunk type to Any #1308

Merged
merged 2 commits into from
Jan 22, 2020
Merged

Change when/switch thunk type to Any #1308

merged 2 commits into from
Jan 22, 2020

Conversation

seldridge
Copy link
Member

This changes the type of the thunk used by when and switch method from => Unit to => Any.

This avoids a warning related to discarding a non-Unit value (-Ywarn-value-discard ) if you do something like what is describe in #1298.

Alternatively, and as I suggested in #1298, I think you could also get rid of this by making the methods polymorphic in the type of the thunk, e.g., apply[A](a: => A): FooContext. However, this is not like withClock where the type of the thunk is returned. Therefore, I opted for the simpler solution of using Any.

Related issue: Fixes #1298

Type of change: other enhancement

Impact: API modification

Development Phase: implementation

Release Notes

  • Prevent warnings from -Ywarn-value-discard in when/switch

Changes the type of the thunk for when and WhenContext methods from
call-by-name Unit to call-by-name Any. This prevents a
warning (-Ywarn-value-discard) where a when thunk is returning
something other than Unit that is then discarded, e.g., another
WhenContext.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Changes the type of switch thunks from call-by-name Unit to
call-by-name Any. This prevents a warning (-Ywarn-value-discard) when
the internals of a switch block return something other than Unit which
is then discarded.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
@seldridge seldridge added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Jan 22, 2020
@seldridge seldridge added this to the 3.3.0 milestone Jan 22, 2020
@seldridge seldridge requested a review from a team as a code owner January 22, 2020 18:38
Copy link
Contributor

@chick chick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok to me. Less warnings is good.

@mergify mergify bot merged commit 993ee4e into master Jan 22, 2020
@seldridge seldridge deleted the issue-1298 branch January 22, 2020 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested when/.elsewhen statement hits Scala warning
2 participants