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

Section 4.5.2 compile error #263

Open
asarkar opened this issue Dec 21, 2024 · 0 comments
Open

Section 4.5.2 compile error #263

asarkar opened this issue Dec 21, 2024 · 0 comments

Comments

@asarkar
Copy link

asarkar commented Dec 21, 2024

Section 4.5.2 Better Syntax

object DisplaySyntax {
  extension [A](value: A)(using p: Display[A]) {
    def display: String = p.display(value)
    def print: Unit = p.print(value)
  }
}

Fails to compile.

value print is not a member of Display[A]. 
An extension method was tried, but could not be fully constructed:  

DisplaySyntax.print[Display[A]](p)( 
/* missing */ summon[Display[Display[A]]])  

failed with:  

No given instance of type Display[Display[A]] was found for parameter p of method print in object DisplaySyntax

This makes sense because the trait Display only has one method, display. print is defined in the Display companion object, and can only be called as Display.print(value).

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