Created
July 24, 2013 03:43
-
-
Save caiiiycuk/6067927 to your computer and use it in GitHub Desktop.
Scala bug SI-6240
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.runtime.universe._ | |
object ParamAccess { | |
val typeString = typeOf[String] | |
} | |
class ParamAccess { | |
import ParamAccess._ | |
def paramo[T: TypeTag](key: String, coll: Map[String, Seq[String]]): Option[T] = { | |
val values = coll.get(key) | |
val valueo = values.map(_(0)) | |
valueo.map(convertText[T](_)) | |
} | |
def convertText[T: TypeTag](value: String): T = { | |
val t = typeOf[T] | |
val any: Any = | |
if (t <:< typeString) value | |
else throw new Exception("Cannot covert " + value + " to " + t) | |
any.asInstanceOf[T] | |
} | |
} | |
class Test extends Runnable() { | |
def run() { | |
val access = new ParamAccess() | |
val value = access.paramo[String]("test", Map("test" -> Seq("value"))) | |
println("Parsed: " + value) | |
} | |
} | |
object XitrumTest { | |
def main(args: Array[String]): Unit = { | |
println("Hello world\n") | |
for (i <- 1 to 10) { | |
new Thread(new Test()).start() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment