scala-2.10

Conditional scalacOptions with SBT

一个人想着一个人 提交于 2019-12-01 04:06:26
问题 I am using a project with cross-build for Scala 2.8, 2.9 and (hopefully) 2.10, using SBT. I would like to add the -feature option when compiling with 2.10 only. In other words, when I compile with a version smaller than 2.10.0, I would like to set the compiler options as: scalacOptions ++= Seq( "-deprecation", "-unchecked" ) and when compiling with a version greater or equal than 2.10.0: scalacOptions ++= Seq( "-deprecation", "-unchecked", "-feature" ) Is there a way to achieve this ? 回答1:

Scala Play 2.2 application crashes after deploying in Heroku: target/start No such file or directory

≯℡__Kan透↙ 提交于 2019-12-01 03:34:45
I've been fighting with this for hours and I can't figure out why after deploying my Scala Play 2.2 application in Heroku I get this stacktrace: 2013-09-30T01:05:09.413177+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=18174 $PLAY_OPTS` 2013-09-30T01:05:10.931893+00:00 app[web.1]: bash: target/start: No such file or directory 2013-09-30T01:05:12.382399+00:00 heroku[web.1]: Process exited with status 127 2013-09-30T01:05:12.414050+00:00 heroku[web.1]: State changed from starting to crashed I've tried several Procfile versions with no success, some examples are: web

reducing an Array of Float using scala.math.max

邮差的信 提交于 2019-11-30 23:34:52
I am confused by the following behavior - why does reducing an Array of Int work using math.max, but an Array of Float requires a wrapped function? I have memories that this was not an issue in 2.9, but I'm not completely certain about that. $ scala -version Scala code runner version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL $ scala scala> import scala.math._ scala> Array(1, 2, 4).reduce(max) res47: Int = 4 scala> Array(1f, 3f, 4f).reduce(max) <console>:12: error: type mismatch; found : (Int, Int) => Int required: (AnyVal, AnyVal) => AnyVal Array(1f, 3f, 4f).reduce(max) ^ scala> def fmax(a:

Runtime resolution of type arguments using scala 2.10 reflection

陌路散爱 提交于 2019-11-30 20:16:34
Given a type declaration, I am able to resolve the type argument. scala> reflect.runtime.universe.typeOf[List[Int]] match {case x:TypeRef => x.args} res10: List[reflect.runtime.universe.Type] = List(Int) For a runtime value, The same method doesn't work. scala> reflect.runtime.currentMirror.reflect(List(42)).symbol.toType match {case x:TypeRef => x.args} res11: List[reflect.runtime.universe.Type] = List(B) Is there a way to overcome the type erasure for reflected values? Michael Lynch An example based on TypeTag knowledge gained from reading Scala: What is a TypeTag and how do I use it? posted

Using Scala 2.10 reflection how can I list the values of Enumeration?

被刻印的时光 ゝ 提交于 2019-11-30 19:22:56
Having a following enumeration object ResponseType extends Enumeration { val Listing, Album = Value } How do I get a list of its vals? If you want to be thorough about this, you need to check that your symbols have Value as a supertype: def valueSymbols[E <: Enumeration: TypeTag] = { val valueType = typeOf[E#Value] typeOf[E].members.filter(sym => !sym.isMethod && sym.typeSignature.baseType(valueType.typeSymbol) =:= valueType ) } Now even if you have the following (which is perfectly legal): object ResponseType extends Enumeration { val Listing, Album = Value val someNonValueThing = "You don't

Kill or timeout a Future in Scala 2.10

廉价感情. 提交于 2019-11-30 18:50:54
Hi, I'm using Scala 2.10 with the new futures library and I'm trying to write some code to test an infinite loop. I use a scala.concurrent.Future to run the code with the loop in a separate thread. I would then like to wait a little while to do some testing and then kill off the separate thread/future. I have looked at Await.result but that doesn't actually kill the future. Is there any way to timeout or kill the new Scala 2.10 futures? I would prefer not having to add external dependencies such as Akka just for this simple part. Do not try it at home. import scala.concurrent._ import scala

What does “reflective access of structural type member method should be enabled…” warning mean in Scala?

天涯浪子 提交于 2019-11-30 17:19:52
After switching to Scala 2.10 I get tons of warnings: reflective access of structural type member method ... should be enabled by making the implicit value language.reflectiveCalls visible What does it mean? Eugene Burmako The warning actually tells where to look in the documentation for an explanation: Test.scala:9: warning: reflective access of structural type member method y should be enabled by making the implicit value language.reflectiveCalls visible. This can be achieved by adding the import clause 'import scala.language.reflectiveCalls' or by setting the compiler option -language

How to list all fields with a custom annotation using Scala's reflection at runtime?

你。 提交于 2019-11-30 17:00:15
问题 I have a custom annotation like class MyProperty(val name: String) extends annotation.StaticAnnotation; // or should I extend something else? For a given class, how can I list all its fields that have this annotation? I'm looking for something like (just guessing): def listProperties[T: ClassTag]: List[(SomeClassRepresentingFields,MyProperty)]; 回答1: This can be done with a TypeTag , by filtering through the members of your input type: import reflect.runtime.universe._ def listProperties[T:

How save a TypeTag and then use it later to reattach the type to an Any (Scala 2.10)

只谈情不闲聊 提交于 2019-11-30 15:54:50
问题 I am trying to make custom heterogeneous lists and maps. Although there are examples around using Manifest, with Scala 2.10 they are deprecated and I should use TypeTags (or Classtags). In the case of maps it seems I can preserve the binding of an Any to a Type using (say) a tuple String->(TypeTag[ _ <: Any ], Any ). My problem is how to get from the recovered TypeTag and an undefined T, to be able to return an instance of TypeTag.tpe - at the point in the code where I have //** How do I use

How save a TypeTag and then use it later to reattach the type to an Any (Scala 2.10)

丶灬走出姿态 提交于 2019-11-30 15:16:40
I am trying to make custom heterogeneous lists and maps. Although there are examples around using Manifest, with Scala 2.10 they are deprecated and I should use TypeTags (or Classtags). In the case of maps it seems I can preserve the binding of an Any to a Type using (say) a tuple String->(TypeTag[ _ <: Any ], Any ). My problem is how to get from the recovered TypeTag and an undefined T, to be able to return an instance of TypeTag.tpe - at the point in the code where I have //** How do I use saved typeTag to define T here?** As written, there are no compiler errors in method get, but T is set