I am trying to test the Java 8 class using rx.Observable
from Scala Test. According to Scala 2.12.0-M3
release notes :
LAMBDA SYNTAX FOR SAM TYPES (EXPERIMENTAL) With M3, this feature is not yet enabled by default. You can enable it using the -Xexperimental
compiler.
When this option is enabled, similarly to Java 8, Scala 2.12 allows creating an instance of any type using one abstract method by passing a lambda.
However, using Gradle and IntelliJ, I cannot get the following for compilation:
val o: rx.Observable[util.Map.Entry[String, _ <: util.Collection[String]]] = ???
val scheduler = new TestScheduler()
scheduler.createWorker().schedule(_ => o.foreach { })
build.gradle
apply plugin: 'scala'
group = 'name.abhijitsarkar.scala'
version = '1.0-SNAPSHOT'
tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = false
scalaCompileOptions.additionalParameters = ["-feature", "-Xexperimental"]
targetCompatibility = "1.8"
}
dependencies {
compile 'org.scala-lang:scala-library:2.12.0-M3'
compile 'com.typesafe.akka:akka-stream-experimental_2.11:2.0.3'
compile 'io.reactivex:rxjava:1.1.0'
testCompile 'org.scalatest:scalatest_2.12.0-M3:3.0.0-M12'
}
source
share