File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
src/compiler/scala/tools/nsc/typechecker Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ trait Infer extends Checkable {
560
560
// explicitly anywhere amongst the formal, argument, result, or expected type.
561
561
// ...or lower bound of a type param, since they're asking for it.
562
562
def canWarnAboutAny = {
563
- val coll = new ContainsAnyCollector (List ( AnyClass , AnyValClass , ObjectClass ) )
563
+ val coll = new ContainsAnyCollector (topTypes )
564
564
def containsAny (t : Type ) = t.dealiasWidenChain.exists(coll.collect)
565
565
val hasAny = containsAny(pt) || containsAny(restpe) ||
566
566
formals.exists(containsAny) ||
@@ -570,7 +570,7 @@ trait Infer extends Checkable {
570
570
}
571
571
if (settings.warnInferAny && context.reportErrors && ! fn.isEmpty && canWarnAboutAny) {
572
572
targs.foreach(_.typeSymbol match {
573
- case sym @ ( AnyClass | AnyValClass | ObjectClass ) =>
573
+ case sym if topTypes contains sym =>
574
574
reporter.warning(fn.pos, s " a type was inferred to be ` ${sym.name}`; this may indicate a programming error. " )
575
575
case _ =>
576
576
})
@@ -1515,6 +1515,8 @@ trait Infer extends Checkable {
1515
1515
}
1516
1516
}
1517
1517
1518
+ private lazy val topTypes : List [Symbol ] = List (AnyClass , AnyValClass , ObjectClass )
1519
+
1518
1520
/** [Martin] Can someone comment this please? I have no idea what it's for
1519
1521
* and the code is not exactly readable.
1520
1522
*/
You can’t perform that action at this time.
0 commit comments