-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Hint about forbidden combination of implicit values and conversions #16735
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ea13cad
Search for Conversions if implicit search fails
ysthakur fc9acd7
Use ctx.implicits.eligible directly
ysthakur 393dab4
Use symbol.showDcl, add sentence on explicitly passing arg
ysthakur 1d7f8dc
Remove test from negAll
ysthakur 208071a
Test implicitly() too; change err msg
ysthakur 3f42e53
Merge branch 'lampepfl:main' into imp-with-conversion-msg
ysthakur 6bded27
Use clearer name
ysthakur 76c826d
Update message to be more generic
ysthakur adc1995
Edit message according to suggestion
ysthakur 82d69a7
Update check
ysthakur 859d30b
Find all implicits first
ysthakur b5755de
Use finalResultType
ysthakur 9579aa5
Filter out Scala 2-style implicit conversions
ysthakur ebb616c
Use typed directly instead of finding conversions
ysthakur 98bf4b2
Fix inversion of if, check for errors properly
ysthakur dda91bb
Make code more readable
ysthakur 2584cf6
Remove unnecessary check for Predef.conforms
ysthakur 95c9dfb
Put check for Predef.conforms back
ysthakur 809f9fc
Use viewExists
ysthakur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- [E172] Type Error: tests/neg/i16453.scala:10:43 --------------------------------------------------------------------- | ||
10 | val fails = summon[String => Option[Int]] // error | ||
| ^ | ||
|No given instance of type String => Option[Int] was found for parameter x of method summon in object Predef | ||
| | ||
|Note: Chaining implicit conversions is no longer allowed in Scala. The following conversions were ignored: | ||
ysthakur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - final given def given_Conversion_Function_Function[T]: Conversion[String => T, String => Option[T]] | ||
|If there is an implicit `Conversion[A, String => Option[Int]]` and an implicit `A` in scope, you need to explicitly pass the argument, e.g. `(using summon[A])` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import scala.language.implicitConversions | ||
|
||
given [T]: Conversion[String => T, String => Option[T]] = ??? | ||
// This one is irrelevant, shouldn't be included in error message | ||
given irrelevant[T]: Conversion[String => T, String => Byte] = ??? | ||
|
||
def test() = { | ||
given foo: (String => Int) = _ => 42 | ||
|
||
val fails = summon[String => Option[Int]] // error | ||
ysthakur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.