Skip to content

Commit ad5a363

Browse files
committed
Fix error message when "import given" is missing
`findHiddenImplicitsCtx` is necessary for the error message to contain the line: > Note: given instance given_Int in object A was not considered because > it was not imported with `import given`. But it looks like we accidentally stopped using it in 1760da3, this commit restores the previous behavior.
1 parent 1ed25ce commit ad5a363

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,8 @@ trait Implicits:
876876
def ignoredInstanceNormalImport = arg.tpe match
877877
case fail: SearchFailureType =>
878878
if (fail.expectedType eq pt) || isFullyDefined(fail.expectedType, ForceDegree.none) then
879-
inferImplicit(fail.expectedType, fail.argument, arg.span) match {
879+
inferImplicit(fail.expectedType, fail.argument, arg.span)(
880+
using findHiddenImplicitsCtx(ctx)) match {
880881
case s: SearchSuccess => Some(s)
881882
case f: SearchFailure =>
882883
f.reason match {

tests/neg/hidden.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/neg/hidden.scala:6:13 ----------------------------------------------------------------------------------
2+
6 | summon[Int] // error
3+
| ^
4+
| no implicit argument of type Int was found for parameter x of method summon in object Predef
5+
|
6+
| Note: given instance given_Int in object A was not considered because it was not imported with `import given`.

0 commit comments

Comments
 (0)