File tree Expand file tree Collapse file tree 6 files changed +40
-14
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 6 files changed +40
-14
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,8 @@ enum ErrorMessageID extends java.lang.Enum[ErrorMessageID]:
175175 OverrideErrorID ,
176176 MatchableWarningID ,
177177 CannotExtendFunctionID ,
178- LossyWideningConstantConversionID
178+ LossyWideningConstantConversionID ,
179+ ImplicitSearchTooLargeID
179180
180181 def errorNumber = ordinal - 2
181182
Original file line number Diff line number Diff line change @@ -124,6 +124,13 @@ abstract class Message(val errorId: ErrorMessageID) { self =>
124124 def explain = self.explain ++ suffix
125125 override def canExplain = true
126126
127+ /** Override with `true` for messages that should always be shown even if their
128+ * position overlaps another messsage of a different class. On the other hand
129+ * multiple messages of the same class with overlapping positions will lead
130+ * to only a single message of that class to be issued.
131+ */
132+ def showAlways = false
133+
127134 override def toString = msg
128135}
129136
Original file line number Diff line number Diff line change @@ -10,19 +10,24 @@ import core.Contexts._
1010 * are suppressed, unless they are of increasing severity. */
1111trait UniqueMessagePositions extends Reporter {
1212
13- private val positions = new mutable.HashMap [(SourceFile , Int ), Int ]
13+ private val positions = new mutable.HashMap [(SourceFile , Int ), Diagnostic ]
1414
1515 /** Logs a position and returns true if it was already logged.
1616 * @note Two positions are considered identical for logging if they have the same point.
1717 */
1818 override def isHidden (dia : Diagnostic )(using Context ): Boolean =
19+ extension (dia1 : Diagnostic ) def hides (dia2 : Diagnostic ): Boolean =
20+ if dia2.msg.showAlways then dia1.msg.getClass == dia2.msg.getClass
21+ else dia1.level >= dia2.level
1922 super .isHidden(dia) || {
20- dia.pos.exists && ! ctx.settings.YshowSuppressedErrors .value && {
23+ dia.pos.exists
24+ && ! ctx.settings.YshowSuppressedErrors .value
25+ && {
2126 var shouldHide = false
2227 for (pos <- dia.pos.start to dia.pos.end)
2328 positions get (ctx.source, pos) match {
24- case Some (level ) if level >= dia.level => shouldHide = true
25- case _ => positions((ctx.source, pos)) = dia.level
29+ case Some (dia1 ) if dia1.hides(dia) => shouldHide = true
30+ case _ => positions((ctx.source, pos)) = dia
2631 }
2732 shouldHide
2833 }
Original file line number Diff line number Diff line change @@ -2515,3 +2515,15 @@ import transform.SymUtils._
25152515 |Inlining such definition would multiply this footprint for each call site.
25162516 | """ .stripMargin
25172517 }
2518+
2519+ class ImplicitSearchTooLargeWarning (limit : Int )(using Context ) extends TypeMsg (ImplicitSearchTooLargeID ):
2520+ override def showAlways = true
2521+ def msg =
2522+ em """ Implicit search problem too large.
2523+ |an implicit search was terminated with failure after trying $limit expressions.
2524+ |
2525+ |You can change the behavior by setting the `-Ximplicit-search-limit` value.
2526+ |Smaller values cause the search to fail faster.
2527+ |Larger values might make a very large search problem succeed.
2528+ | """
2529+ def explain = " "
Original file line number Diff line number Diff line change @@ -1145,15 +1145,7 @@ trait Implicits:
11451145 if result then
11461146 var c = ctx
11471147 while c.outer.typer eq ctx.typer do c = c.outer
1148- report.echo(
1149- em """ Implicit search problem too large.
1150- |an implicit search was terminated with failure after trying $limit expressions.
1151- |
1152- |You can change the behavior by setting the `-Ximplicit-search-limit` value.
1153- |Smaller values cause the search to fail faster.
1154- |Larger values might make a very large search problem succeed.
1155- | """ ,
1156- ctx.source.atSpan(span))(using c)
1148+ report.warning(ImplicitSearchTooLargeWarning (limit), ctx.source.atSpan(span))(using c)
11571149 else
11581150 h.root.nestedSearches = nestedSearches + 1
11591151 result
Original file line number Diff line number Diff line change 1616 |
1717
1818longer explanation available when compiling with `-explain`
19+ -- [E168] Type Warning: tests/neg-custom-args/i13838.scala:8:50 --------------------------------------------------------
20+ 8 | def liftF[F[_], A](fa: F[A]): F[Foo[A]] = map(fa)(???) // error
21+ | ^
22+ | Implicit search problem too large.
23+ | an implicit search was terminated with failure after trying 1000 expressions.
24+ |
25+ | You can change the behavior by setting the `-Ximplicit-search-limit` value.
26+ | Smaller values cause the search to fail faster.
27+ | Larger values might make a very large search problem succeed.
You can’t perform that action at this time.
0 commit comments