File tree 6 files changed +73
-1
lines changed
compiler/src/dotty/tools/dotc/reporting
6 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -2848,10 +2848,17 @@ class MissingImplicitArgument(
2848
2848
i " The following implicits in scope can be implicitly converted to ${pt.show}: " +
2849
2849
ignoredConvertibleImplicits.map { imp => s " \n - ${imp.symbol.showDcl}" }.mkString
2850
2850
)
2851
+ def importSuggestionAddendum : String =
2852
+ arg.tpe match
2853
+ // If the failure was caused by an underlying NoMatchingImplicits, compute the addendum for its expected type
2854
+ case noMatching : NoMatchingImplicits => // FIXME also handle SynthesisFailure
2855
+ ctx.typer.importSuggestionAddendum(noMatching.expectedType)
2856
+ case _ =>
2857
+ ctx.typer.importSuggestionAddendum(pt)
2851
2858
super .msgPostscript
2852
2859
++ ignoredInstanceNormalImport.map(hiddenImplicitNote)
2853
2860
.orElse(noChainConversionsNote(ignoredConvertibleImplicits))
2854
- .getOrElse(ctx.typer. importSuggestionAddendum(pt) )
2861
+ .getOrElse(importSuggestionAddendum)
2855
2862
2856
2863
def explain (using Context ) = userDefinedImplicitNotFoundMessage(explain = true )
2857
2864
.getOrElse(" " )
Original file line number Diff line number Diff line change
1
+ -- [E172] Type Error: tests/neg/i8827a.scala:16:26 ---------------------------------------------------------------------
2
+ 16 | summon[Order[List[Foo]]] // error
3
+ | ^
4
+ | No given instance of type pkg.Order[List[pkg.Foo]] was found for parameter x of method summon in object Predef.
5
+ | I found:
6
+ |
7
+ | pkg.Order.orderList[pkg.Foo](/* missing */summon[pkg.Order[pkg.Foo]])
8
+ |
9
+ | But no implicit values were found that match type pkg.Order[pkg.Foo].
10
+ |
11
+ | The following import might fix the problem:
12
+ |
13
+ | import pkg.Implicits.orderFoo
14
+ |
Original file line number Diff line number Diff line change
1
+ package pkg
2
+
3
+ trait Order [A ]
4
+
5
+ object Order {
6
+ implicit def orderList [A ](implicit orderA : Order [A ]): Order [List [A ]] = ???
7
+ }
8
+
9
+ class Foo
10
+
11
+ object Implicits {
12
+ implicit def orderFoo : Order [Foo ] = ???
13
+ }
14
+
15
+ @ main def main : Unit =
16
+ summon[Order [List [Foo ]]] // error
Original file line number Diff line number Diff line change
1
+ -- [E172] Type Error: tests/neg/i8827b.scala:16:28 ---------------------------------------------------------------------
2
+ 16 | summon[Order[Option[Foo]]] // error
3
+ | ^
4
+ |No given instance of type pkg.Order[Option[pkg.Foo]] was found for parameter x of method summon in object Predef.
5
+ |I found:
6
+ |
7
+ | pkg.Order.given_Order_Option[pkg.Foo](/* missing */summon[pkg.Order[pkg.Foo]])
8
+ |
9
+ |But no implicit values were found that match type pkg.Order[pkg.Foo].
10
+ |
11
+ |The following import might fix the problem:
12
+ |
13
+ | import pkg.Givens.orderFoo
14
+ |
Original file line number Diff line number Diff line change
1
+ package pkg
2
+
3
+ trait Order [A ]
4
+
5
+ object Order {
6
+ given [A ](using orderA : Order [A ]): Order [Option [A ]] = ???
7
+ }
8
+
9
+ class Foo
10
+
11
+ object Givens {
12
+ given orderFoo : Order [Foo ] = ???
13
+ }
14
+
15
+ @ main def main : Unit =
16
+ summon[Order [Option [Foo ]]] // error
Original file line number Diff line number Diff line change 7
7
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]])
8
8
|
9
9
| But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo].
10
+ |
11
+ | The following import might make progress towards fixing the problem:
12
+ |
13
+ | import scala.math.Ordered.orderingToOrdered
14
+ |
You can’t perform that action at this time.
0 commit comments