-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Extension method could not be constructed due to ambiguous methods #11243
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
Comments
Did you try to complete the example by hand i.e. first
and then
what did you get? |
That was fruitful, thanks! Well, it seems I can use the Monad when completing by hand. Both pure and flatMap are good, but the problem is in the last line where I try to use the extension method it has trouble finding the right type...
First two println's work but when adding the last line I get the error...
|
I just tried it myself: WriterTest.transformerMonad.flatMap(writerExample)(doubleOdd) gives the ambiguity error but WriterTest.transformerMonad[EString].flatMap(writerExample)(doubleOdd) is OK. The problem here is that at the point where the ambiguity is raised we have not analyzed |
When retrying after an ambiguous implicit, we now make use of all the information in the prototype, including ignored parts. We also try to match formal parameters with actually given arguments. Fixes scala#11243 Fixes scala#5773, which previously was closed with a more detailed error message.
When retrying after an ambiguous implicit, we now make use of all the information in the prototype, including ignored parts. We also try to match formal parameters with actually given arguments. Fixes scala#11243 Fixes scala#5773, which previously was closed with a more detailed error message.
That's great, thanks! I'm glad it was not just a simple user error. |
When retrying after an ambiguous implicit, we now make use of all the information in the prototype, including ignored parts. We also try to match formal parameters with actually given arguments. Fixes scala#11243 Fixes scala#5773, which previously was closed with a more detailed error message.
When retrying after an ambiguous implicit, we now make use of all the information in the prototype, including ignored parts. We also try to match formal parameters with actually given arguments. Fixes scala#11243 Fixes scala#5773, which previously was closed with a more detailed error message.
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.0.0-M3
Minimized code
In the code sample, I've implemented a simple Monad transformer called Transformer that wraps another Monad. For some reason the internal Monad[F] is ambiguous and the code does not compile. I pretty much ported this from Scala 2.x code, so I'm not sure if the problem is my misunderstanding or a bug in the typer.
Output
Expectation
Should be able to use the transformerMonad method to create a given instance.
For reference here is the sample code in Scala 2.x
https://gist.github.com/justinhj/79f223bfb75791d40a6a5fd431ad86ea
The monad is WriterT rather than the simplified Transformer here.
The text was updated successfully, but these errors were encountered: