diff --git a/src/main/scala/leon/LeonContext.scala b/src/main/scala/leon/LeonContext.scala
index 8b3a250c2188246a325dc8341586725ab8873d94..8677364ee1cd5948a80001a72424e45a0538afcf 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)
 }