From 7a570c8df5a15724ea94b1f30f75a18b32b0a266 Mon Sep 17 00:00:00 2001 From: Manos Koukoutos <emmanouil.koukoutos@epfl.ch> Date: Thu, 8 Oct 2015 15:05:14 +0200 Subject: [PATCH] Properly type findOption --- src/main/scala/leon/LeonContext.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/leon/LeonContext.scala b/src/main/scala/leon/LeonContext.scala index 8b3a250c2..8677364ee 100644 --- a/src/main/scala/leon/LeonContext.scala +++ b/src/main/scala/leon/LeonContext.scala @@ -6,6 +6,8 @@ import leon.utils._ import java.io.File +import scala.reflect.ClassTag + /** 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 * exception of the reporter). */ @@ -20,11 +22,11 @@ case class LeonContext( // @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 // with one in Main,allOptions, but is different - def findOption[A](optDef: LeonOptionDef[A]): Option[A] = options.collectFirst { - case LeonOption(`optDef`, value) => value.asInstanceOf[A] + def findOption[A: ClassTag](optDef: LeonOptionDef[A]): Option[A] = options.collectFirst { + 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) } -- GitLab