-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix/18681 unreduced summon from fallback #19490
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
base: main
Are you sure you want to change the base?
Changes from all commits
6deac90
eb6db96
c148144
b344eb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Error: tests/neg/summonFrom-implicit-not-found.scala:8:8 ------------------------------------------------------------ | ||
8 |val x = summonMissing // error | ||
| ^^^^^^^^^^^^^ | ||
| there is no Missing! | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from summonFrom-implicit-not-found.scala:4 | ||
4 |inline def summonMissing = compiletime.summonFrom { | ||
| ^ | ||
5 | case m: Missing => m | ||
6 |} | ||
--------------------------------------------------------------------------------------------------------------------- | ||
-- [E172] Type Error: tests/neg/summonFrom-implicit-not-found.scala:9:8 ------------------------------------------------ | ||
9 |val y = summonMissing2 // error | ||
| ^^^^^^^^^^^^^^ | ||
| there is no Missing! | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from summonFrom-implicit-not-found.scala:7 | ||
7 |inline def summonMissing2 = compiletime.summonInline[Missing] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
--------------------------------------------------------------------------------------------------------------------- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@annotation.implicitNotFound("there is no Missing!") | ||
trait Missing | ||
|
||
inline def summonMissing = compiletime.summonFrom { | ||
case m: Missing => m | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder what should be the error for @annotation.implicitNotFound("there is no Missing1!")
trait Missing1
@annotation.implicitNotFound("there is no Missing2!")
trait Missing2
inline def summonMissing = compiletime.summonFrom {
case m: Missing1 => m
case m: Missing2 => m
}
val x = summonMissing We can choose the first one, last one, concatenate the messages. Not sure what would be best. This might also mean that we loose information in which implicits are accepted here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case it might be better to do inline def summonMissing = compiletime.summonFrom {
case m: Missing1 => m
case m: Missing2 => m
case _ => compiletime.error("no Missing1 or Missing2 found")
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently I think that we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I also wonder which error message(s) it should show. I choosed the last message rather than accumulating errors with the aim of minimizing diff in the dotty codebase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree with you. If we concat multiple implicitNotFounds that encourage users to import something at the same time, users could follow the instruction only to find ambiguous implicits, which could confuse users, but suggest all the possible actions they can take. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Should/Could we report unexhaustiveness as error in summonFrom with an error message better than "cannot reduce summonFrom with ..." in the similar way as we warn on unexhaustive pattern matches to enums? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminiscent of implicitNotFound on parent classes. IIRC scala 2 appends (accumulates); there is an open dotty ticket. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you think it is better to keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That sounds like a better solution. I assume that we will still see the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the feedback. I'll address this. |
||
inline def summonMissing2 = compiletime.summonInline[Missing] | ||
val x = summonMissing // error | ||
val y = summonMissing2 // error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it fail fast when a case results in missing implicit instance rather than continuing remaining cases?