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

Investigate alternatives to caffeine cache key AnyRef type constraint #603

Open
lewisjkl opened this issue Nov 9, 2021 · 1 comment
Open

Comments

@lewisjkl
Copy link
Collaborator

lewisjkl commented Nov 9, 2021

The Caffeine cache builder requires that the key and value types of the cache extend Object. In Scala this is analogous to AnyRef. To make scalacache compatible, I've added a type constraint on the key (K <: AnyRef). The strange thing is that this only seems to be necessary on Scala 2.12 and not on 2.13 or 3.

@ronnnnnnnnnnnnn
Copy link
Contributor

I think this probably has to do with this issue fixed in scala-2.13. As for a solution here, I think the only option is to wrap the key type when its a value type in order for it to compile in scala-2.12. This can be done either at the point of use (like the change by @lewisjkl in the tests), or alternatively if we don't want the user to need to deal with it we can maybe try to find a way for the wrapping to be done automatically for value types (I guess that might be possible using macros maybe?)

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

No branches or pull requests

2 participants