Skip to content

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