Skip to content

Commit

Permalink
Use runReporting lint-performance
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Mar 4, 2022
1 parent b95d511 commit 6654dcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/Reporting.scala
Expand Up @@ -395,6 +395,7 @@ object Reporting {
object LintRecurseWithDefault extends Lint; add(LintRecurseWithDefault)
object LintUnitSpecialization extends Lint; add(LintUnitSpecialization)
object LintMultiargInfix extends Lint; add(LintMultiargInfix)
object LintPerformance extends Lint; add(LintPerformance)

sealed trait Feature extends WarningCategory { override def summaryCategory: WarningCategory = Feature }
object Feature extends Feature { override def includes(o: WarningCategory): Boolean = o.isInstanceOf[Feature] }; add(Feature)
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/transform/LambdaLift.scala
Expand Up @@ -18,6 +18,7 @@ import Flags._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.{LinkedHashMap, LinkedHashSet}
import scala.tools.nsc.Reporting.WarningCategory.LintPerformance

abstract class LambdaLift extends InfoTransform {
import global._
Expand Down Expand Up @@ -502,7 +503,7 @@ abstract class LambdaLift extends InfoTransform {
}
}
if (settings.warnCaptured)
reporter.warning(tree.pos, s"Modification of variable $name within a closure causes it to be boxed.")
runReporting.warning(tree.pos, s"Modification of variable $name within a closure causes it to be boxed.", LintPerformance, sym)
treeCopy.ValDef(tree, mods, name, tpt1, factoryCall)
case ValDef(_, _, _, _) => tree
case Return(Block(stats, value)) =>
Expand Down
11 changes: 11 additions & 0 deletions test/files/pos/ignore-wperf.scala
@@ -0,0 +1,11 @@
// scalac: -Werror -Wperformance -Wconf:cat=lint-performance:s

class C {
var x = 0

def f: (Int => Int) = {
var y = x
z => y + 1
}
}
//test/files/neg/ignore-wperf.scala:7: warning: Modification of variable y within a closure causes it to be boxed.

0 comments on commit 6654dcf

Please sign in to comment.