Skip to content

compiletime.summonInline should yield the missing implicit error #12412

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

Closed
soronpo opened this issue May 11, 2021 · 3 comments · Fixed by #12428
Closed

compiletime.summonInline should yield the missing implicit error #12412

soronpo opened this issue May 11, 2021 · 3 comments · Fixed by #12428

Comments

@soronpo
Copy link
Contributor

soronpo commented May 11, 2021

Compiler version

v3.0.0-RC3

Minimized code

@annotation.implicitNotFound("Missing")
trait Missing
val x = compiletime.summonInline[Missing] 

Output

3 |val x = compiletime.summonInline[Missing]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |        cannot reduce summonFrom with
  |         patterns :  case given t @ _:Missing

Expectation

expecting "Missing" error.

@nicolasstucki I can take care of this, by implementing summonInline directly in the compiler.
If this is acceptable, I will submit a PR.

@nicolasstucki
Copy link
Contributor

Yes, summonInline should be implemented directly in the compiler. It should share as much logic as possible with summonFrom. Maybe we can even turn it around and implement summonFrom based on summonInline.

@soronpo
Copy link
Contributor Author

soronpo commented May 11, 2021

@nicolasstucki I have a related question. As an experiment I implemented

transparent inline def summonOrError[T]: Either[String, T] =

This either enables us to get the error message and possibly pattern match on it as well.
It worked well, but the problem is that within a case statement, we loose refinement:

inline compiletime.summonOrError[Foo] match
  case Right(v : Foo) => v
  case Left(msg) if msg == "Some Message" => compiletime.error("Got my message")
  case Left(msg) => compiletime.error(msg) //not possible to 

Do you think something can be done to allow this concept, or we say "nevermind" as this logic can be implemented in macros?

@nicolasstucki
Copy link
Contributor

Something can be done but it is probably tricky. Macros might be simpler to handle in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants