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

Covariance breaks implicit parameter inference #10099

Open
scabug opened this issue Dec 7, 2016 · 3 comments
Open

Covariance breaks implicit parameter inference #10099

scabug opened this issue Dec 7, 2016 · 3 comments

Comments

@scabug
Copy link

scabug commented Dec 7, 2016

Hi,

The sample below fails to compile when In is covariant. It compiles when In is invariant.

trait In[+T]
trait Converter[T]

implicit val StringConverter: Converter[String] = ???
implicit val BooleanConverter: Converter[Boolean] = ???

implicit def convert[T: Converter](value: String): In[T] = ???

def doSomething(f: In[String]): Unit = ???

doSomething("foo")

Regards

@scabug
Copy link
Author

scabug commented Dec 7, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10099?orig=1
Reporter: Stéphane Landelle (slandelle)
Affected Versions: 2.11.8, 2.12.1

@scabug
Copy link
Author

scabug commented Dec 7, 2016

Stéphane Landelle (slandelle) said:
I raised the priority because I can't see a way for us to upgrade to Scala 2.12 for now.

Up until now, we were actually using an alias for "In" and we inadvertently didn't propagate the covariance.
This was probably a mistake, but still, it didn't the job here.

With Scala 2.12, we are now forced to propagate the variance to the alias, hence us hitting this problem.

Any help greatly appreciated.

@scabug
Copy link
Author

scabug commented Dec 7, 2016

Stéphane Landelle (slandelle) said:
Following my previous comment, I figured out that we can still use our ugly invariant type alias with @uncheckedVariance.
Still, it would be great to have a proper solution.

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

1 participant