Skip to content

GROOVY-8241 SAM parameter type inference for explicit parameter#643

Closed
avafanasiev wants to merge 1 commit intoapache:masterfrom
avafanasiev:master
Closed

GROOVY-8241 SAM parameter type inference for explicit parameter#643
avafanasiev wants to merge 1 commit intoapache:masterfrom
avafanasiev:master

Conversation

@avafanasiev
Copy link
Contributor

@daniellansun
Copy link
Contributor

+1
@paulk-asert any thoughts on the PR?

@asfgit asfgit closed this in bd5191d Dec 13, 2017
@daniellansun
Copy link
Contributor

Merged. Thanks :-)

asfgit pushed a commit that referenced this pull request Dec 13, 2017
asfgit pushed a commit that referenced this pull request Dec 13, 2017
@avafanasiev
Copy link
Contributor Author

Thanks for merge!


static def testPredicate() {
foo { it ->
it.toUpperCase()
Copy link

Choose a reason for hiding this comment

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

I'm confused :) This works because foo happens to always pass a String to p::test, but what if it passed new Object() instead? If testPredicate were @CompileStatic I would expect a compile error here. Is this disparity intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually you can't pass anything except String to Predicate<? super String> p . Cause it should be able to be assigned to captured type '? super String' . This behavior matches java's lambda behavior.

Copy link

@ghost ghost Feb 14, 2018

Choose a reason for hiding this comment

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

Oh, you're right. I forgot Groovy's interpretation of <? super X> is simply <X> :)

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