"+" method shadowed by any2stringadd
See original GitHub issueHi! Thanks for a wonderful library.
We’re hitting an interesting issue:
@newtype case class Demo(value: Int) {
def +(another: Demo): Demo = ???
}
def demo(d: Demo) = d + d
^ type mismatch;
found : (...).Demo
(which expands to) (...).Demo.Type
required: String
If I just say d +
, I get missing argument list for method + in class any2stringadd
. As far as I could find out, that method gets special treatment and can’t be unimported.
I took a look at the implementation of newtypes and as far as I could tell methods from the class are moved to an implicit class next to it, to which a conversion called Demo.Ops$newtype
is applied - when I apply it manually, or import it (import Demo._
or by exact name) it compiles as expected. I assume any2stringadd
just has higher precedence because it’s imported.
Is there something scala-newtype can do to allow this name in methods on newtypes?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
scala - Shadow any2stringadd when implicitly converting Symbol ...
I don't like either solution. My question is, is there any other way to rephrase my program to convince scala to select my...
Read more >any2stringadd implicit should be removed from Predef #194
There should at least be a way to turn this implicit off. ... What I do is shadow the definition of Predef.any2stringadd by...
Read more >Scala Standard Library 2.13.6 - scala.Predef.any2stringadd
Injects String concatenation operator + to any classes. Annotations: @deprecated; Deprecated. (Since version 2.13.0) Implicit injection of + is deprecated.
Read more >any2stringadd - scala.Predef.any2stringadd
Returns the runtime class representation of the object. Returns the runtime class representation of the object. returns. a class object corresponding to the ......
Read more >Pull - fs2-core_2.11 0.9.5 javadoc
Allows acquiring elements from a stream in a resource safe way, ... O, R] to any2stringadd[Pull[F, O, R]] performed by method any2stringadd in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, I actually hadn’t checked that (just extrapolated a bit from the newtype example, sorry!).
That works. But not on a newtype…
I’m going to go ahead and close this, but if there are still unresolved issues, please re-open.