File tree 6 files changed +40
-14
lines changed
compiler/src/dotty/tools/dotc
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]:
175
175
OverrideErrorID ,
176
176
MatchableWarningID ,
177
177
CannotExtendFunctionID ,
178
- LossyWideningConstantConversionID
178
+ LossyWideningConstantConversionID ,
179
+ ImplicitSearchTooLargeID
179
180
180
181
def errorNumber = ordinal - 2
181
182
Original file line number Diff line number Diff line change @@ -124,6 +124,13 @@ abstract class Message(val errorId: ErrorMessageID) { self =>
124
124
def explain = self.explain ++ suffix
125
125
override def canExplain = true
126
126
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
+
127
134
override def toString = msg
128
135
}
129
136
Original file line number Diff line number Diff line change @@ -10,19 +10,24 @@ import core.Contexts._
10
10
* are suppressed, unless they are of increasing severity. */
11
11
trait UniqueMessagePositions extends Reporter {
12
12
13
- private val positions = new mutable.HashMap [(SourceFile , Int ), Int ]
13
+ private val positions = new mutable.HashMap [(SourceFile , Int ), Diagnostic ]
14
14
15
15
/** Logs a position and returns true if it was already logged.
16
16
* @note Two positions are considered identical for logging if they have the same point.
17
17
*/
18
18
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
19
22
super .isHidden(dia) || {
20
- dia.pos.exists && ! ctx.settings.YshowSuppressedErrors .value && {
23
+ dia.pos.exists
24
+ && ! ctx.settings.YshowSuppressedErrors .value
25
+ && {
21
26
var shouldHide = false
22
27
for (pos <- dia.pos.start to dia.pos.end)
23
28
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
26
31
}
27
32
shouldHide
28
33
}
Original file line number Diff line number Diff line change @@ -2515,3 +2515,15 @@ import transform.SymUtils._
2515
2515
|Inlining such definition would multiply this footprint for each call site.
2516
2516
| """ .stripMargin
2517
2517
}
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:
1145
1145
if result then
1146
1146
var c = ctx
1147
1147
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)
1157
1149
else
1158
1150
h.root.nestedSearches = nestedSearches + 1
1159
1151
result
Original file line number Diff line number Diff line change 16
16
|
17
17
18
18
longer 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