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

Fix #3984: SAM closures returning Unit may need adaptation #3988

Merged
merged 2 commits into from
Feb 13, 2018

Conversation

smarter
Copy link
Member

@smarter smarter commented Feb 12, 2018

If the abstract method in a SAM trait has a generic result type that is
instantiated to Unit, we need to adapt closures implementing this trait
to return BoxedUnit. This isn't necessary for
Unit-returning closures without an explicit SAM type because in the backend they're implemented
using the JProcedure* SAMs (see DottyBackendInterface#Closure) that
already handle adapting to BoxedUnit.

If the abstract method in a SAM trait has a generic result type that is
instantiated to Unit, we need to adapt closures implementing this trait
to return BoxedUnit. This isn't necessary for Unit-returning closures
without an explicit SAM type because in the backend they're implemented
using the `JProcedure*` SAMs (see DottyBackendInterface#Closure) that
already handle adapting to BoxedUnit.
@smarter smarter requested a review from odersky February 12, 2018 16:39
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

LGTM!

@smarter smarter merged commit 726dcc0 into scala:master Feb 13, 2018
@allanrenucci allanrenucci deleted the fix-closure-unit branch February 13, 2018 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants