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

Correct signature of Record.map() #5341

Closed
wants to merge 1 commit into from
Closed

Correct signature of Record.map() #5341

wants to merge 1 commit into from

Conversation

Ostralyan
Copy link

It should be possible to map using mappers of specific types of sub-record

Unfortunately Java does not support type covariance in this way by default

So probably <? extends Record> is the correct type of mapper

It should be possible to map using mappers of specific types of sub-record

Unfortunately Java does not support type covariance in this way by default

So probably <? extends Record> is the correct type of mapper
@lukaseder
Copy link
Member

Thank you very much for your suggestion.

Hmm, if anything were to be fixed at all with that type signature, it would have to be <? super Record> due to the rules of PECS. But I doubt the current type hierarchy will support this. We've had this discussion several times previously on the mailing list. I'll look into this later with some more feedback.

@lukaseder
Copy link
Member

I'm closing this as won't fix. As it stands now, the suggested change is incorrect. Yes, the current signature of the Record.map(RecordMapper) method is unsatisfactory, but I don't see any means of improving it short of adding a recursive generic type on Record<R extends Record<R>> which would be asking for serious trouble (details here)

@lukaseder lukaseder closed this Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants