Skip to content

Commit dd8b8c1

Browse files
authored
Fix compiler warnings (#615)
* start clearing warnings * Fix even more warnings * Fix two typos * Further cleanup; disable warnings as errors for now
1 parent f920a8c commit dd8b8c1

24 files changed

Lines changed: 64 additions & 67 deletions

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ThisBuild / scalacOptions ++= Seq(
1414
"-unchecked", // Warn on generated code assumptions
1515
"-feature", // Warn on features that requires explicit import
1616
"-Wunused", // Warn on unused imports
17-
"-Ypatmat-exhaust-depth", "40" // Increase depth of pattern matching analysis
17+
"-Ypatmat-exhaust-depth", "40", // Increase depth of pattern matching analysis
18+
// "-Xfatal-warnings", // Treat Warnings as errors to guarantee code quality in future changes
1819
)
1920

2021
// Enforce UTF-8, instead of relying on properly set locales

src/main/scala/viper/silver/ast/Ast.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ trait Info {
358358
case _ => Seq.empty
359359
}
360360

361-
def removeUniqueInfo[T <: Info]: Info = this match {
361+
def removeUniqueInfo[T <: Info : ClassTag]: Info = this match {
362362
case ConsInfo(a, b) => MakeInfoPair(a.removeUniqueInfo[T], b.removeUniqueInfo[T])
363-
case t: T => NoInfo
363+
case _: T => NoInfo
364364
case info => info
365365
}
366366
}

src/main/scala/viper/silver/ast/Expression.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ case class DomainFuncApp(funcname: String, args: Seq[Exp], typVarMap: Map[TypeVa
389389
//Strangely, the copy method is not a member of the DomainFuncApp case class,
390390
//therefore, We need this method that does the copying manually
391391
def copy(funcname: String = this.funcname, args: Seq[Exp] = this.args, typVarMap: Map[TypeVar, Type] = this.typVarMap): (Position, Info, Type, String, ErrorTrafo) => DomainFuncApp ={
392-
DomainFuncApp(this.funcname,args,typVarMap)
392+
DomainFuncApp(funcname,args,typVarMap)
393393
}
394394
}
395395
object DomainFuncApp {
@@ -403,7 +403,7 @@ case class BackendFuncApp(backendFunc: BackendFunc, args: Seq[Exp])
403403
(val pos: Position = NoPosition, val info: Info = NoInfo, val errT: ErrorTrafo = NoTrafos)
404404
extends AbstractDomainFuncApp {
405405
override lazy val check : Seq[ConsistencyError] = args.flatMap(Consistency.checkPure)
406-
override def func = (p: Program) => backendFunc
406+
override def func = (_: Program) => backendFunc
407407
def funcname = backendFunc.name
408408
override def typ = backendFunc.typ
409409
}

src/main/scala/viper/silver/ast/utility/Consistency.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package viper.silver.ast.utility
88

99
import viper.silver.ast._
1010
import viper.silver.ast.utility.rewriter.Traverse
11-
import viper.silver.parser.{FastParser, FastParserCompanion}
11+
import viper.silver.parser.FastParserCompanion
1212
import viper.silver.verifier.ConsistencyError
1313
import viper.silver.{FastMessage, FastMessaging}
1414

src/main/scala/viper/silver/ast/utility/Functions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Functions {
2525
def allSubexpressionsIncludingUnfoldings(program: Program)(func: Function): Seq[Exp] = {
2626
var visitedPredicates = Set[String]()
2727
var subexpressions = allSubexpressions(func)
28-
var unfoldings = new ListBuffer[Unfolding]
28+
val unfoldings = new ListBuffer[Unfolding]
2929
unfoldings ++= (subexpressions map (e => e.deepCollect{case u@Unfolding(_, _) => u})).flatten
3030
var i = 0
3131
while (i < unfoldings.length){

src/main/scala/viper/silver/ast/utility/ViperStrategy.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ object ViperStrategy {
179179
Trafos(
180180
newMetaData._3.eTransformations,
181181
newMetaData._3.rTransformations,
182-
newMetaData._3.nTransformations.orElse(Some(n.asInstanceOf[ErrorNode])))
182+
newMetaData._3.nTransformations.orElse(Some(n)))
183183
} else {
184184
/* Keep already attached transformations (if any) */
185185
newMetaData._3
186186
}
187187
}
188-
now
188+
now.withMeta(newMetaData._1, newMetaData._2, newNodeTrafo)
189189
} else {
190190
now
191191
}

src/main/scala/viper/silver/ast/utility/rewriter/Strategy.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package viper.silver.ast.utility.rewriter
88
import viper.silver.ast.utility.rewriter.Traverse.Traverse
99

10+
import scala.annotation.unused
1011
import scala.collection.mutable
1112
import scala.reflect.runtime.{universe => reflection}
1213

@@ -92,7 +93,7 @@ trait StrategyInterface[N <: Rewritable] {
9293
* rewritten.
9394
* @return Updated node that will be built into the AST
9495
*/
95-
protected def preserveMetaData(old: N, now: N, directlyRewritten: Boolean): N = now
96+
protected def preserveMetaData(@unused old: N, now: N, @unused directlyRewritten: Boolean): N = now
9697
}
9798

9899
/**

src/main/scala/viper/silver/ast/utility/rewriter/TRegex.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package viper.silver.ast.utility.rewriter
88

9+
import scala.annotation.unused
910
import scala.reflect.runtime.{universe => reflection}
1011

1112
/*
@@ -140,10 +141,10 @@ class NMatch[N <: Rewritable : TypeTag](val pred: N => Boolean, val rewrite: Boo
140141

141142
/**
142143
* Provide information about the actions that occur if node n matches on this matcher
143-
* @param n node used for traversion
144-
* @return list of traversion infos
144+
* @param n node used for traversal
145+
* @return list of traversal infos
145146
*/
146-
def getTransitionInfo(n: Rewritable): Seq[TransitionInfo] = if (rewrite) Seq(MarkedForRewrite()) else Seq.empty[TransitionInfo]
147+
def getTransitionInfo(@unused n: Rewritable): Seq[TransitionInfo] = if (rewrite) Seq(MarkedForRewrite()) else Seq.empty[TransitionInfo]
147148

148149
}
149150

src/main/scala/viper/silver/cfg/utility/LoopDetector.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package viper.silver.cfg.utility
88

99
import java.util.concurrent.atomic.AtomicInteger
1010

11-
import viper.silver.ast.utility.ViperStrategy
1211
import viper.silver.ast.utility.rewriter.Traverse
1312
import viper.silver.ast.{Exp, If, Info, Infoed, LocalVar, MakeInfoPair, NoInfo, Seqn, Stmt}
1413
import viper.silver.cfg._

src/main/scala/viper/silver/frontend/SilFrontend.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ trait SilFrontend extends DefaultFrontend {
242242
Succ({e.initProperties(); e})
243243
}
244244
else Fail(err_list)
245-
case fail @ Parsed.Failure(_, index, extra) =>
245+
case fail @ Parsed.Failure(_, index, _) =>
246246
val msg = fail.trace().longAggregateMsg
247247
val (line, col) = fp.lineCol.getPos(index)
248248
Fail(List(ParseError(s"Expected $msg", SourcePosition(file, line, col))))

0 commit comments

Comments
 (0)