Skip to content
Snippets Groups Projects
Commit 7a570c8d authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Properly type findOption

parent 900e027d
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ import leon.utils._ ...@@ -6,6 +6,8 @@ import leon.utils._
import java.io.File import java.io.File
import scala.reflect.ClassTag
/** Everything that is part of a compilation unit, except the actual program tree. /** Everything that is part of a compilation unit, except the actual program tree.
* Contexts are immutable, and so should all there fields (with the possible * Contexts are immutable, and so should all there fields (with the possible
* exception of the reporter). */ * exception of the reporter). */
...@@ -20,11 +22,11 @@ case class LeonContext( ...@@ -20,11 +22,11 @@ case class LeonContext(
// @mk: This is not typesafe, because equality for options is implemented as name equality. // @mk: This is not typesafe, because equality for options is implemented as name equality.
// It will fail if an LeonOptionDef is passed that has the same name // It will fail if an LeonOptionDef is passed that has the same name
// with one in Main,allOptions, but is different // with one in Main,allOptions, but is different
def findOption[A](optDef: LeonOptionDef[A]): Option[A] = options.collectFirst { def findOption[A: ClassTag](optDef: LeonOptionDef[A]): Option[A] = options.collectFirst {
case LeonOption(`optDef`, value) => value.asInstanceOf[A] case LeonOption(`optDef`, value:A) => value
} }
def findOptionOrDefault[A](optDef: LeonOptionDef[A]): A = def findOptionOrDefault[A: ClassTag](optDef: LeonOptionDef[A]): A =
findOption(optDef).getOrElse(optDef.default) findOption(optDef).getOrElse(optDef.default)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment