-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
EitherIdOpsBinCompat0 causes scala-newtype tagged type to not compile #2491
Comments
Thanks so much for investigating and reporting. This is rather unfortunate. Two value classes over compatible types can't share the same field name. We (cats) should have been more careful with polluting such a broad namespace. At the moment I couldn't think of a fix that doesn't break binary compatibility. |
I did some preliminary experiments, there might be a fix that is both source (mostly except the |
Sounds good. I'm all for a Probably not a low hanging fruit but let me know if I can help in anyway. |
We are going to address this one in #2514 |
This is fixed #2614 |
Quite an interesting issue here. Basically, I was using scala-newtype together with cats 1.4.0 which I upgraded from 1.2.0 just today and my project will not longer compile. I isolated the issue to this:
I had a
@newtype case class Foo(value : String)
which, at some point, compiles to:And the compiler says:
I've manually pasted the code generated from
scala-newtype
and removed the dependency and this still happens.If I change
Foo
'svalue
to some other name, saydef abc: String = $this$.asInstanceOf[String]
then it works.It seems that 380f721 added the syntax
final class EitherIdOpsBinCompat0[A](val value: A) extends AnyVal{...}
which clashes with myvalue
defined in my tagged type. To verify this, I also used the namea
and that also causes the same issue but this time withfinal class ValidatedIdOpsBinCompat0[A](val a: A) extends AnyVal{...}
. IntelliJ'sclick to open implementation
when used on thefoo.value
symbol actually takes me toEitherIdOpsBinCompat0[A](val value: A)
which confirms my suspicion.The obvious workaround is to not have newtypes with
a
orvalue
as fields but I imagine these are popular names for this kind of use.The text was updated successfully, but these errors were encountered: