You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class PreferredPrompt(val preference: String)
object Greeter:
def greet(name: String)(using prompt: PreferredPrompt) =
println(s"Welcome, $name. The system is ready.")
println(prompt.preference)
object JillsPrefs:
given jillsPrompt: PreferredPrompt =
PreferredPrompt("Your wish> ")
object JoesPrefs:
given joesPrompt: PreferredPrompt =
PreferredPrompt("relax> ")
import JillsPrefs.jillsPrompt
import JoesPrefs.joesPrompt
val x = Greeter.greet("Who's there?") // error
gives this error message:
-- Error: i11066.scala:15:37 ---------------------------------------------------
15 |val x = Greeter.greet("Who's there?")
| ^
|ambiguous implicit arguments: both lazy value joesPrompt in object JoesPrefs and lazy value jillsPrompt in object JillsPrefs match type PreferredPrompt of parameter prompt of method greet in object Greeter
Expected
A description of JoesPrefs and JillsPrefs as given instances, not lazy vals. Lazy vals reveals underlying implementation details that should be omitted.
The text was updated successfully, but these errors were encountered:
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 11, 2021
Uh oh!
There was an error while loading. Please reload this page.
This code:
gives this error message:
Expected
A description of
JoesPrefs
andJillsPrefs
as given instances, not lazy vals. Lazy vals reveals underlying implementation details that should be omitted.The text was updated successfully, but these errors were encountered: