ghik / silencer

Scala compiler plugin for warning suppression
Apache License 2.0
255 stars 33 forks source link

Fails when used with scoverage #2

Closed joprice closed 8 years ago

joprice commented 8 years ago

Seems like the plugin doesn't preserve tree positions. I see this error when I use it with scoverage:

[info] [info] ======= Position error
[info] [info] Unpositioned tree #1858
[info] [info]    unpositioned [L   0 P# 1906] #1858   [NoPosition]    Typed      // Typed
[info] [info]       enclosing [L   7        ] #1906   [120:334]       Template   // {
[info] [info]         sibling [L  12 P# 1906] #72     [334]           Select     // Select(Ident(scala), AnyRef)
[info] [info]         sibling [L   0 P# 1906] #21     [NoPosition]    noSelfType // term _
[info] [info]         sibling [L  12 P# 1906] #330    [334]           DefDef     // term <init>
[info] [info]         sibling [L   8 P# 1906] #853    [124:158]       ClassDef   // Wrapper(i: Option[Int])
[info] [info]         sibling [L   8 P# 1906] #1905   [135]           ModuleDef  // term Wrapper
[info] [info]         sibling [L   9 P# 1906] #1024   [161:189]       ValDef     // i: java.lang.Integer = 1
[info] [info]         sibling [L   9 P# 1906] #323    [165]           DefDef     // term i
[info] [info]         sibling [L   0 P# 1906] #1858   [NoPosition]    Typed      // Typed
[info] [info]
[info] [info] While validating #1908
[info] [info] [L   5        ] #1908   [65:334]        PackageDef // import com.github.ghik.silencer.silent
[info] [info]
[info] [info] Children:
[info] [info]   [L   5 P# 1908] #79     [65:65]         Ident      // i
[info] [info]   [L   5 P# 1908] #27     [65:103]        Import     // com.github.ghik.silencer.silent
[info] [info]   [L   7 P# 1908] #1907   [105:334]       ModuleDef  // Silence {
[info] [info] =======
[info] scala.reflect.internal.Positions$ValidateException: Unpositioned tree #1858
[info]  at scala.reflect.internal.Positions$class.positionError$1(Positions.scala:102)
[info]  at scala.reflect.internal.Positions$class.validate$1(Positions.scala:112)
[info]  at scala.reflect.internal.Positions$class.validate$1(Positions.scala:142)
[info]  at scala.reflect.internal.Positions$class.validate$1(Positions.scala:142)
[info]  at scala.reflect.internal.Positions$class.validate$1(Positions.scala:142)
[info]  at scala.reflect.internal.Positions$class.validatePositions(Positions.scala:147)
[info]  at scala.reflect.internal.SymbolTable.validatePositions(SymbolTable.scala:16)
[info]  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:103)
[info]  at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:441)
[info]  at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:432)
[info]  at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:441)
[info]  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:94)
[info]  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:93)
[info]  at scala.collection.Iterator$class.foreach(Iterator.scala:750)
[info]  at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
[info]  at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
[info]  at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)
[info]  at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)
ghik commented 8 years ago

The plugin doesn't modify trees in any way, including their positions, so I can't see why it would cause the crash. Anyway, I'll try to reproduce the problem. If your project is available on github or you have some simple example project, please mention it.

joprice commented 8 years ago

I'll try to reproduce it in a minimal project.

joprice commented 8 years ago

https://github.com/joprice/silencer-scoverage-issue

ghik commented 8 years ago

Thanks for the reproduction.

I disabled the silencer-plugin in your sample project and compilation still crashes. To me it looks like scoverage plugin can't properly handle "annotation ascriptions", i.e. annotations used on expressions (not sure how this syntax is called).

joprice commented 8 years ago

I see. Thanks for looking into it. I'll take it up with scoverage.